Hacker News new | past | comments | ask | show | jobs | submit login

I got the sense that Erlang overlaps somewhat with node.js in terms of what one might use it for. Could anyone familiar with both compare them?



I have experience with both Erlang and Node.js so I feel it's acceptable if I answer this question.

I would use Erlang for anything I would have used Node.js for and I haven't touched Node.js since I've learned Erlang (and Elixir).

- Erlang allows both CPU and IO concurrency.

- Like Node.js, all I/O in Erlang is non-blocking. The difference is that in Erlang your code looks synchronous. There is no callback/promise/whatever sewage all over your codebase, the Erlang VM and its schedulers take care of that for you.

- Messaging is built directly into Erlang, so communicating across OS processes, and within processes, is trivial. In Node.js you have to implement this yourself and will screw it up.

- Node.js doesn't give you any tools for fault-tolerance or distribution, Erlang is best in class for this.

- Erlang has pattern matching and tail recursion. This helps you create much more concise programs than JavaScript does.

- Because Erlang is CPU concurrent and Node.js only offers I/O concurrency, Erlang programs are incredibly consistent in their response times. In Node.js, as your programs grow and take up more CPU time (thus blocking the event loop) you will notice your 99th percentile response times are way above the average.


Your second point is extremely important. My elixir code is way cleaner than my node.js code. You aren't constantly thinking about async stuff because each connection is in its own process. Just write your code and let the process scheduler do the hard work. I don't think I could ever go back to node for a medium or large web app. Elixir has been so much simpler, even though I've been learning the language as I go.

It also has benchmarked extremely well...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: