12

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.

Jonathan Leffler
  • 666,971
  • 126
  • 813
  • 1,185
hawkeye
  • 31,052
  • 27
  • 133
  • 271
  • a brief description for future - https://medium.com/@ssumit/concurrency-models-that-most-developers-should-know-44c0ed707413 – singhsumit Dec 23 '18 at 19:07

1 Answers1

2

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).

rlegendi
  • 9,744
  • 2
  • 35
  • 47