[erlang-questions] node.js compared to erlang

Joe Armstrong <>
Sun Oct 3 22:25:48 CEST 2010


On Sun, Oct 3, 2010 at 9:07 PM, Kaiduan Xie <> wrote:
> Joe,
>
> - cross platform error detection and recovery
> (i.e. to make something fault tolerant needs at least 2 machines,
> think the case when one machine crashes - the second machine must be
> able to take over)
>
> Can you give us a real-life example on this point? I have not seen an
> illustration for this in your book, and in Francesco/Simon's book.


When you spawn_link a process on a remote node it
behaves just like a local process (apart from latency) - if the entire node or
machine dies you'll get an exit. You can arrange that proceses in a supervisor
tree are on remote nodes and thus try to restart them or restart them
on a different
node.

In the books I guess we don't make the point strongly enough, but the
link between processes is something that can exist across machine boundaries.
So whatever applies on one machine (regarding error recovery) should work
across machine boundaries.

The process architectures on single nodes and in distributed systems are
broadly similar with the exception that entire groups of processes will die
if a node dies, even if they are not linked together.

Most real life examples need only pretty simple things like replicated
data in mnesia and a cross machine takeover mechanism.

> The
> upcoming Erlang/OTP-In-Action also does not touch this area. OTP
> supervisor structure seems focusing on re-start process on local
> machine.

But there is no need why this should be so - supervisor structures
could cross machine boundaries if necessary.

The essential point is that spawn_link works over machine boundaries
delivering exit signals across machine boundaries if processes die.
The supervisors are just wrappers that encapsulate this mechanism in a
convenient way.

/Joe

>
> Of course Mnesia is a good example. I would like to see a code example
> from other projects too.
>
> Best regards,
>
> /Kaiduan
> On Sun, Oct 3, 2010 at 2:40 PM, Joe Armstrong <> wrote:
>> You have to ask why was erlang designed? why was node.js designed?
>>
>> I don't know why node.js ws desiged - I guess so you could write servers
>> in js.
>>
>> Erlang was designed for building soft real-time fault-tolerant systems
>> that could be
>> upgraded without taking them out of service. These design criteria led
>> to erlang features like:
>>
>> - fast per/process garbage collection
>> - ability to change code on-the-fly (ie the module reload stuff, with the
>>  ability to run old and new module code at the same time)
>> - several orthogonal error detection mechanisms (catch-throw/links/ ...)
>> - cross platform error detection and recovery
>>  (ie to make something fault tolerant needs at least 2 machines,
>>   think the case when one machine crashes - the second machine must be
>>  able to take over)
>>
>> In the erlang system there is quite a lot going on behind the scenes to make
>> sure this all happens without the user being aware of it - to first
>> approximation
>> you can spread processes and database tables over multiple nodes and
>> it will behave in a reasonable manner ...
>>
>> I don't think things like have any correspondence in node.js - I guess if
>> an entire node.js node crashes the user would not expect another node
>> to take over
>> in a seamless manner.
>>
>> The fun stuff in Erlang has to do with how the failure model interacts with
>> code changing, moving code around, upgrading code without stopping the system
>> and so on - these characteristics are extremely important if you want to
>> build a 24x7 system with zero down time - less so if you just want to serve up
>> pages as fast as possible and don't care if you take the system out of service
>> for upgrades or errors.
>>
>> Erlang was designed for building fault-tolerant systems - node.js was not
>>
>> Cheers
>>
>> /Joe
>>
>>
>>
>>
>> On Sun, Oct 3, 2010 at 5:00 PM, Pablo Platt <> wrote:
>>> Hi
>>>
>>> I'm using erlang and I love it.
>>> I'm not trying to create an argument but to better understand the power of
>>> erlang.
>>>
>>> In what areas erlang dominates and what areas will you consider using node.js?
>>> For example, would you consider building something like rabbitmq or ejabberd in
>>> node.js?
>>> Or maybe you'll use node.js just for a simple single chat room but erlang for
>>> anything complicated than that.
>>>
>>> Are there a fundamental differences in performance or stability or use in
>>> distributed systems?
>>>
>>> Ulf Wiger commented on the comparison of erlang and node.js
>>> and said that erlang solves the problem of non blocking functions which might be
>>> very hard for other languages.
>>> http://journal.dedasys.com/2010/04/29/erlang-vs-node-js
>>>
>>> Thanks
>>>
>>>
>>>
>>
>> ________________________________________________________________
>> erlang-questions (at) erlang.org mailing list.
>> See http://www.erlang.org/faq.html
>> To unsubscribe; mailto:
>>
>>
>


More information about the erlang-questions mailing list