Node.js or Erlang

ConcurrencyErlangMulticorenode.js

Concurrency Problem Overview


I really like these tools when it comes to the concurrency level it can handle.

Erlang/OTP looks like much more stable solution but requires much more learning and a lot of diving into functional language paradigm. And it looks like Erlang/OTP makes it much better when it comes to multi-core CPUs (correct me if I am wrong).

But which should I choose? Which one is better in the short and long term perspective?

My goal is to learn a tool which makes scaling my Web projects under high load easier than traditional languages.

Concurrency Solutions


Solution 1 - Concurrency

I would give Erlang a try. Even though it will be a steeper learning curve, you will get more out of it since you will be learning a functional programming language. Also, since Erlang is specifically designed to create reliable, highly concurrent systems, you will learn plenty about creating highly scalable services at the same time.

Solution 2 - Concurrency

I can't speak for Erlang, but a few things that haven't been mentioned about node:

  • Node uses Google's V8 engine to actually compile javascript into machine code. So node is actually pretty fast. So that's on top of the speed benefits offered by event-driven programming and non-blocking io.
  • Node has a pretty active community. Hop onto their IRC group on freenode and you'll see what I mean
  • I've noticed the above comments push Erlang on the basis that it will be useful to learn a functional programming language. While I agree it's important to expand your skillset and get one of those under your belt, you shouldn't base a project on the fact that you want to learn a new programming style
  • On the other hand, Javascript is already in a paradigm you feel comfortable writing in! Plus it's javascript, so when you write client side code it will look and feel consistent.
  • node's community has already pumped out tons of modules! There are modules for redis, mongodb, couch, and what have you. Another good module to look into is Express (think Sinatra for node)

Check out the video on yahoo's blog by Ryan Dahl, the guy who actually wrote node. I think that will help give you a better idea where node is at, and where it's going.

Keep in mind that node still is in late development stages, and so has been undergoing quite a few changes—changes that have broke earlier code. However, supposedly it's at a point where you can expect the API not to change too much more. So if you're looking for something fun, I'd say node is a great choice.

Solution 3 - Concurrency

I'm a long-time Erlang programmer, and this question prompted me to take a look at node.js. It looks pretty damn good.

It does appear that you need to spawn multiple processes to take advantage of multiple cores. I can't see anything about setting processor affinity though. You could use taskset on linux, but it probably should be parametrized and set in the program.

I also noticed that the platform support might be a little weaker. Specifically, it looks like you would need to run under Cygwin for Windows support.

Looks good though.


Edit

Node.js now has native support for Windows.

Solution 4 - Concurrency

I'm looking at the same two alternatives you are, gotts, for multiple projects.

So far, the best razor I've come up with to decide between them for a given project is whether I need to use Javascript. One existing system I'm looking to migrate is already written in Javascript, so its next version is likely to be done in node.js. Other projects will be done in some Erlang web framework because there is no existing code base to migrate.

Another consideration is that Erlang scales well beyond just multiple cores, it can scale to a whole datacenter. I don't see a built-in mechanism in node.js that lets me send another JS process a message without caring which machine it is on, but that's built right into Erlang at the lowest levels. If your problem isn't big enough to need multiple machines or if it doesn't require multiple cooperating processes, this advantage isn't likely to matter, so you should ignore it.

Erlang is indeed a deep pool to dive into. I would suggest writing a standalone functional program first before you start building web apps. An even easier first step, since you seem comfortable with Javascript, is to try programming JS in a more functional style. If you use jQuery or Prototype, you've already started down this path. Try bouncing between pure functional programming in Erlang or one of its kin (Haskell, F#, Scala...) and functional JS.

Once you're comfortable with functional programming, seek out one of the many Erlang web frameworks; you probably shouldn't be writing your app directly to something low-level like inets at this late stage. Look at something like http://nitrogenproject.com/">Nitrogen</a>;, for instance.

Solution 5 - Concurrency

While I'd personally go for Erlang, I'll admit that I'm a little biased against JavaScript. My advice is that you evaluate few points:

  1. Are you reusing existing code in either of those languages (both in terms of source code, and programmer experience!)
  2. Do you need/want on-the-fly updates without stopping the application (This is where Erlang wins by default - its runtime was designed for that case, and OTP contains all the tools necessary)
  3. How big is the expected traffic, in terms of separate, concurrent operations, not bandwidth?
  4. How "parallel" are the operations you do for each request?

Erlang has really fine-tuned concurrency & network-transparent parallel distributed system. Depending on what exactly is the project, the availability of a mature implementation of such system might outweigh any issues regarding learning a new language. There are also two other languages that work on Erlang VM which you can use, the Ruby/Python-like Reia and Lisp-Flavored Erlang.

Yet another option is to use both, especially with Erlang being used as kind of "hub". I'm unsure if Node.js has Foreign Function Interface system, but if it has, Erlang has C library for external processes to interface with the system just like any other Erlang process.

Solution 6 - Concurrency

It looks like Erlang performs better for deployment in a relatively low-end server (512MB 4-core 2.4GHz AMD VM). This is from SyncPad's experience of comparing Erlang vs Node.js implementations of their virtual whiteboard server application.

Solution 7 - Concurrency

There is one more language on the same VM that erlang is -> Elixir

It's a very interesting alternative to Erlang, check this one out.

Also it has a fast-growing web framework based on it-> Phoenix Framework

Solution 8 - Concurrency

whatsapp could never achieve the level of scalability and reliability without erlang https://www.youtube.com/watch?v=c12cYAUTXXs

Solution 9 - Concurrency

I will Prefer Erlang over Node. If you want concurrency, Node can be substituted by Erlang or Golang because of their light weight processes.

Erlang is not easy to learn so requires a lot of effort but its community is active so can get help from that, this is only the reason why people prefer Node .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser80805View Question on Stackoverflow
Solution 1 - ConcurrencyJustin EthierView Answer on Stackoverflow
Solution 2 - ConcurrencyJarsenView Answer on Stackoverflow
Solution 3 - ConcurrencydsmithView Answer on Stackoverflow
Solution 4 - ConcurrencyWarren YoungView Answer on Stackoverflow
Solution 5 - Concurrencyp_lView Answer on Stackoverflow
Solution 6 - ConcurrencyadibView Answer on Stackoverflow
Solution 7 - ConcurrencyNoDisplayNameView Answer on Stackoverflow
Solution 8 - ConcurrencyHenry H.View Answer on Stackoverflow
Solution 9 - ConcurrencySumit PugaliaView Answer on Stackoverflow