16

Question

Can anyone recommend a library for Ocaml that offers an actor-based concurrency model for distributed computing?

Note here the "actor-based" and "distributed" - I'd like the actor-based model, but also I want seamless handling of distributed actors - I don't want to write the protocol to talk to them. The library should ideally also offer standard patterns such a supervisor trees and so on.


Motivation

I love Erlang concurrency model and ability to transparently deal with distributed processes and local processes together. However, I find Erlang's syntax to be rather limiting and would like a much more expressive language. I'm considering moving from Erlang to either Scala or Ocaml.

I know Scala has the Akka library which seems to offer a nice Scala version of Erlang's concurrency model. I'd like to see what is available on the Ocaml side.


Aside

I'd also be happy to hear about actor-based concurrency libraries for other languages (particularly C++, Haskell, Python and Ruby).

MGwynne
  • 3,512
  • 1
  • 23
  • 35
  • 4
    in a language whose implementation still doesn't support multithreading, what would one do with an actor library? – Kim Stebel Sep 27 '11 at 09:26
  • 2
    there is more than one implementation – ygrek Sep 27 '11 at 10:00
  • 5
    @KimStebel: Multithreading is no prerequisite for distributed computing. In fact, you can use Erlang without any SMP as well. – Matthias Benkard Sep 27 '11 at 10:01
  • 2
    erlang has language level support for actors, that is hardly comparable. – Kim Stebel Sep 27 '11 at 10:54
  • 2
    @ygrek: is there one that supports multithreading? – Kim Stebel Sep 27 '11 at 10:55
  • 2
    Note that Scala _comes_ with an Actor library based on Erlang. Akka is an alternative library which departs a bit from Erlang model for various reasons. There are two other Actor libraries for Scala as well. – Daniel C. Sobral Sep 27 '11 at 11:46
  • @DanielC.Sobral , but does the standard Actor library offer reasonable support for distributed computing? The reason I mention Akka is that it seems to be geared to this. – MGwynne Sep 27 '11 at 12:15
  • 5
    Kim Stebel, to be precise, inria's ocaml supports multithreading. But you probably meant SMP - and there is oc4mc. Linear performance suffers, as expected. – ygrek Sep 27 '11 at 13:10
  • 2
    @MGwynne Akka _is_ geared for it, and it is superior to the standard library implementation. Who said replicating Erlang model in all its details is best? In particular, Erlang has a VM made specifically for what it does, why Scala has to run on JVM, subject to different strengths and limitations. – Daniel C. Sobral Sep 27 '11 at 16:53
  • 2
    Maybe I'm missing something here: actors are running in completely different processes, right (CSP)? Why is the threading issue relevant? OK, I can see that each actor needs a thread to pull messages off the incoming queue and another to send messages out - but OCaml's threads seem to be sufficient for that, right? – aneccodeal Sep 27 '11 at 17:20
  • 1
    @ygrek - are you saying there is more than one implementation of actors in OCaml? – aneccodeal Sep 27 '11 at 17:22
  • 1
    aneccodeal, no, I was talking about ocaml implementations/forks. – ygrek Sep 28 '11 at 06:58

5 Answers5

11

While it may not be the exact same model that Erlang uses, you might want to take a look at JoCaml, which is based on the join calculus.

Matthias Benkard
  • 15,497
  • 4
  • 39
  • 47
  • Looks interesting! Any idea how popular/well-used/supported this is? I'd rather not use something actively-developed that is going to lose support within a year. – MGwynne Sep 28 '11 at 05:10
  • 1
    I'm not sure about adoption. A data point: the mailing list archives are pretty much empty. In addition, at some point, development ceased for a while (2003-2007, I believe). On the other hand, JoCaml has been in existence for quite a number of years. I wouldn't expect a lot of API instability. – Matthias Benkard Sep 29 '11 at 09:36
5

You can take a look at parvel -- message passing library/framework for ocaml. It's not yet complete, but already includes some primitives for programming with actors.

larhat
  • 443
  • 2
  • 5
3

"I'm considering moving from Erlang to either Scala or Ocaml."

You should consider scalang, which allows you to program in Scala, but use Erlang's actors.

I recently saw a talk on the language by @moonpolysoft (Cliff Moon) at the Strange Loop conference. Cliff Moon developed it for https://boundary.com/ and open-sourced it earlier this year.

luther07
  • 362
  • 1
  • 6
2

You'll probably spend a lot of time reading about:

Scala and F# have akka and MailboxProcessor which are being used in production apps (note: Scala actors and, I think, akka, are very tied to Hotspot; I'm not sure if MailboxProcessor can be used under MONO)

Haskell has userspace threads and at least 1 actor implementation which i don't know a lot about

For ML and ocaml, some libs which are probably not widely used: poly/ML and oc4mc

and netmulticore

Gene T
  • 5,156
  • 1
  • 24
  • 24
1

Although, it is a very old question things have changed since it was asked. C++ has an actor model implementation which is quite robust. It also provides distributed computing features as asked by OP. The homepage is at http://actor-framework.org/

Further, it can also make us of OpenCL for HPC the module for which is located at github in one of the repositories.

Shiv
  • 1,912
  • 1
  • 15
  • 21