Search code examples
clojureakkaactoragentpulsar

Clojure equivalent of "Actors"


I've been looking into Elixir and Akka recently, and that got me thinking: what's the equivalent in Clojure?

  • I found a couple of "message throughput comparison" posts about agents vs actors, but they were from 8 years ago
  • One answer used to be agents ... but that's not quite the same thing (agents don't seem to have their own logic, they're "acted upon" by external code)
  • Another somewhat recent answer was Pulsar fibres (closer, but ... is that still maintained?)

(I am aware that it's possible that I'm "asking the wrong question here", hopefully this isn't too open ended)


Solution

  • Rich Hickey in his 2008 talk "Clojure Concurrency" explicitly distinguishes agents from actors, mentioning several ways that they are different from each other. Search for "agent" and "actor" in the transcript of this talk if you want to find some of those comments quickly: https://github.com/matthiasn/talk-transcripts/blob/master/Hickey_Rich/ClojureConcurrency.md

    More here on clojure.org on the differences between agents and actors: https://clojure.org/about/state#actors

    Another conversation from someone that knows more about the original Hewitt actor model than I do, apparently, that may be useful to read: http://www.dalnefre.com/wp/2010/06/actors-in-clojure-why-not/

    My understanding is that if you want Erlang-style actors, you basically need unreliable message queues between threads/processes. Between different processes, there are any number of ways to get unreliable message passing, none built into Clojure, but all available via Java interop.