Question

I'm curious if Erlang could be killed by Node.js which could be extreme popular, fast and have web workers. Is it possible? Why?

But what about multiple-processor concurrency? Aren't threads necessary to scale programs to multi-core computers? Processes are necessary to scale to multi-core computers, not memory-sharing threads. The fundamentals of scalable systems are fast networking and non-blocking design—the rest is message passing. In future versions, Node will be able to fork new processes (using the Web Workers API ) which fits well into the current design.

Was it helpful?

Solution

Node.js and Erlang are quite different beasts on the savannah.

Examples:

Node.js is centered around a cooperative multitasking model, reminiscent of Python Twisted or Rubys EventMachine. Erlang, on the contrary, is a preemptively multitasked system complete with schedulers and so on.

Node.js implements JavaScript which is a prototype-based OO language with an imperative base and several functional ideas. Erlang implements, essentially, an augmented lambda-calculus in the usual functional style.

Node.js is centered mostly around a single machine, where each request is handled in order. The coming Web workers and the multi-node extension let you use all CPUs of the machine. Erlang is designed to seamlessly integrate multiple nodes, which are meant to be used to let a cluster of (more than one) Erlang physical machine be seamlessly communicating to each other.

Node.js takes the usual stance of proactive fault-mitigation found in most languages. Erlang on the other hand takes a reactive fault-mitigation stance: the system is built to survive even if errors otherwise unaccounted for occur. In the worst case by letting another physical machine take over.

Node.js relies heavily on JIT to obtain speed. Erlang is a more standard compiled language. The ramifications is that Erlang may be better suited for soft-realtime as the wall-clock time of a piece of code is usually more predictable.

Discussion:

It should be clear to you that the approach to the proposed problem is vastly different from the two languages. Hence, it is probably worth keeping both around for this very reason. In other words, I don't think one language will completely replace the other. Node.js has a familiarity strength. Erlang has a distinct strength w.r.t. robustness.

disclaimer: I hack Erlang.

OTHER TIPS

Not quite probable.

  • With mutable data structures of JS, there are much more ways to shoot oneself in the foot while handling shared data.
  • Erlang solutions can be easily and transparently clustered; node.js doesn't seem to provide comparable support.
  • Erlang VM seemingly provides more tools to look at running systems.
  • Erlang is compiled statically and has some static typing support; this usually increases reliability.
  • V8 runs fast only because of JIT, and JIT often consumes lots of memory. Erlang's VM can probably handle more load at the same CPU and memory budget.

Node.js surely has a number of upsides, but none of these seem to be going to oust Erlang from its place. My hope that node.js will oust PHP instead :)

Node.js is an answer to the question "How do you build an efficient concurrent system by bolting an event loop onto a language with ridiculously few lines of code". And the question itself is kind of brilliant, too.

Erlang is a much more complete answer to the concurrency-problem, the language, the compiler, the libraries, everything is build around fault tolerance, distribution and concurrency from the ground up.

A full list of Erlang's advantages? That's a long list, I don't have that much time. A few samples:

  • one lightweight, scalable concurrency mechanism (processes) instead of a lightweight one (events) plus a heavyweight one (web workers)
  • supervisor hierarchies among processes
  • soft real-time capabilities (due to language design, compiler and runtime support)
  • processes maintain a call stack, events in node.js forget where they come from, which makes error messages/stack traces a lot less insightful
  • no need to nest parentheses/indentation in continuation passing style to create callbacks, the event loop and continuation passing are managed by compiler/runtime

Node.js has the distinct advantage of using JavaScript, so it will probably beat Erlang in terms of popularity wherever node.js is good enough, which is in a whole lot of places.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top