tags:

views:

269

answers:

4

Possible Duplicate:
Where is Erlang used and why?

What are the use cases for which Erlang does particularly better than mainstream languages and meet the investment?

+2  A: 

The ideal use case is a distributed system based on sending/receiving messages, e.g. a chat server or a distributed key-value database. Erlang is based on the so called-actor model. The actor is a piece of code which listens for messages and reacts. Each actor runs in its own thread. The threads are very lightweight compared to Java or pthreads. A message to an actor might cause it to send a message to another actor and so on. The message can also be a piece of code. Erlang allows hot-swapping of code without shutting down the system. You might also consider Scala and F# as alternatives as they support the actor model on a library level and are truly general purpose languages. Erlang does not support mutable variables.

Stefan
Saying that Erlang actors run on separate threads is a little misleading, they are real processes, but not OS processes, in that they are separate and non-shared and the only way to pass data between them is by messages.
rvirding
+1  A: 

This is one thing that sold it to my coworker:

Apache vs Yaws

Apache dies out at around 4000 parallel sessions. Erlang worked better under a much higher load (~90k). The idea is that as a functional language, Erlang can handle concurrency much better than imperative languages.

Aillyn
+1 Interesting graph although not a lot of details on the specifics of the benchmark are published...
ChristopheD
+7  A: 

Probably the biggest draw for Erlang is that it is (for the most part) always thread safe. With the restriction on single core processors, there is a big draw for doing parallel coding. This can be done in languages like C++ or Java with Threads, but it can be very difficult to get everything to run without subtle bugs.

With Erlang, writing parallel code is much easier, and although it may not have the sequential speed of other langauges, it is a lot safer and you end up spending less time (and often no time) debugging the tricky parallel gotcha.

As a particular example, Erlang is very good a dealing with web interfaces. For reliablily Yaws can handle a huge amount of parallel sessions, and for speed, Misultin runs request faster than any other web interface I have seen.

I would say that Erlang is worth the investment, because at the very least, since it is a functional langauge it gets you into the habbit of writting good sequential code too (Following function language patterns)

Olives
+1  A: 

Deployment vs Instrinsic Merit

Like Ruby and Rails, Erlang has intrinsic merits but its scope of deployment is more of a matter of what things are already written in it. Right now, the thing that gets Erlang deployed is RabbitMQ.

Threads Considered Harmful

With respect to intrinsic merit, the appeal of Erlang is probably not so much the language but rather that it is a framework based on the Actor Model and message-passing rather than shared-memory-concurrency.

Many of us are quite certain that shared-memory threads are the wrong way to introduce concurrency. It is just too close to impossible to visualize and test the possible interactions, and it's possible for a program that used to work to start failing as it is run on hardware with more actual concurrency, even though the thread model and the binary code have not changed at all.

DigitalRoss