Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Communicating Sequential Processes [CSP] an alternative to the actor model in Scala?

In a 1978 Paper by Hoare we have an idea called Communicating Sequential Processes. This is used by Go, Occam, and in Clojure in core.async.

Is it possible to use CSP as an alternative to the Actor Model in Scala? (I'm seeing JCSP but I'm wondering if this is the only option, if it is mature, and if anyone uses it).

EDIT - I'm also seeing Communicating Scala Objects as an alternative to JCSP in Scala. But those of these seem to be tied to real threads - which seems to miss one of the benefits of CSP, being to get away from the memory resource cost of keeping large numbers of threads always active.

like image 874
hawkeye Avatar asked Nov 24 '13 05:11

hawkeye


1 Answers

You should consult this document, but in general there are a few differences:

  • Channels are anonymous while actors have identities
  • In CSP, you use channels to transmit messages, but actors can directly contact each other.
  • In CSP communication is done in the form of rendezvous (i.e., it is synchronous). Actors support asynchronous message passing.

And yes, it is possible to use CSP as an alternative to the Actor model if these differences are acceptable in your position. I don't have any experience with JCSP but I wouldn't recommend using that specific library (the reason is as I see there aren't any activity in the project since 2011).

like image 107
rlegendi Avatar answered Nov 15 '22 23:11

rlegendi