views:

1358

answers:

12

What libraries exist for other programming languages to provide an Erlang-style concurrency model (processes, mailboxes, pattern-matching receive, etc.)?

Note: I am specifically interested in things that are intended to be similar to Erlang, not just any threading or queueing library.

+6  A: 

Microsoft Concurrency and Coordination Runtime for .NET.

The CCR is appropriate for an application model that separates components into pieces that can interact only through messages. Components in this model need means to coordinate between messages, deal with complex failure scenarios, and effectively deal with asynchronous programming.

Frank Krueger
+5  A: 

Scala supports actors. But I would not call scala intentionally similar to Erlang.

Nonetheless scala is absolutely worth taking a look!

Mo
+5  A: 

Also kilim is a library for java, that brings erlang style message passing/actors to the Java language.

Mo
+5  A: 

Message Passing Interface (MPI) (http://www-unix.mcs.anl.gov/mpi/) is a highly scalable and robust library for parallel programming, geared original towards C but now available in several flavors http://en.wikipedia.org/wiki/Message_Passing_Interface#Implementations. While the library doesn't introduce new syntax, it provides a communication protocol to orchestrate the sharing of data between routines which are parallelizable.

Traditionally, it is used in large cluster computing rather than on a single system for concurrency, although multi-core systems can certainly take advantage of this library.

Another interesting solution to the problem of parallel programming is OpenMP, which is an attempt to provide a portable extension on various platforms to provide hints to the compiler about what sections of code are easily parallelizable.

For example (http://en.wikipedia.org/wiki/OpenMP#Work-sharing_constructs):

#define N 100000
int main(int argc, char *argv[])
{
  int i, a[N];
  #pragma omp parallel for
  for (i=0;i<N;i++) 
     a[i]= 2*i;
  return 0;
}

There are advantages and disadvantages to both, of course, but the former has proven to be extremely successful in academia and other heavy scientific computing applications. YMMV.

jcsalterego
+3  A: 

For python you can try using processing module.

cnu
+4  A: 

Mike Rettig created a .NET library called Retlang and a Java port called Jetlang that is inspired by Erlang's concurrency model.

dpp
+9  A: 

Ulf Wiger had a great post recently on this topic - here are the properties he defines as required before you can call something "Erlang Style Concurrency":

  • Fast process creation/destruction
  • Ability to support >> 10 000 concurrent processes with largely unchanged characteristics.
  • Fast asynchronous message passing.
  • Copying message-passing semantics (share-nothing concurrency).
  • Process monitoring.
  • Selective message reception.

Number 2 above is the hardest to support in VMs and language implementations that weren't initially designed for concurrency. This is not to knock Erlang-ish concurrency implementations in other languages, but a lot of Erlang's value comes from being able to create millions of processes, which is pretty damn hard if the process abstraction has a 1-1 relationship with an OS-level thread or process. Ulf has a lot more on this in the link above.

argv0
+3  A: 

Termite for Gambit Scheme.

Doug Currie
+1  A: 

Warning: shameless plug!

I developed a library for this kind of message passing in Haskell: Erlang-style Distributed Haskell.

Volker

ShiDoiSi
+3  A: 

If you are using Ruby, take a look at Revactor: [http://revactor.org/][1]

Revactor is an Actor model implementation for Ruby 1.9 built on top of the Rev high performance event library. Revactor is primarily designed for writing Erlang-like network services and tools.

Take a look at this code sample:

  myactor = Actor.spawn do
    Actor.receive do |filter|
      filter.when(:dog) { puts "I got a dog!" }
    end
  end

Revactor only runs on Ruby 1.9. I believe the author of the library has discontinued maintaining it but the documentation on their site is very good.

You might also want to take a look at Reia: a ruby-like scripting language built on top of the Erlang VM. Reia is the new project of the creator of Revactor: Tony Arcieri.

luccastera
+3  A: 

Microsoft's Not-Production-Ready Answer to Erlang: Microsoft Axum

HVS
+1  A: 

JoCaml extends OCaml with join calculus for concurrent and distributed programming.

ygrek