3

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)

agam
  • 5,064
  • 6
  • 31
  • 37

1 Answers1

10

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.

andy_fingerhut
  • 1,486
  • 8
  • 10
  • 3
    It's of course very easy to simulate unreliable message queues: start with reliable message queues, and arbitrarily drop messages! – amalloy Dec 24 '19 at 07:44
  • I guess I should clarify that when I say "unreliable message queues" I mean "message queues without a guarantee of reliable delivery", I did not mean "message queues with a guarantee of unreliability" :-) – andy_fingerhut Dec 24 '19 at 07:46
  • Yes, I get that they're different, I was wondering whether (in the decade since ...) anyone felt the need to create something equivalent to actors in clojure, and how the usual suspects (core.async, agents, fibers via pulsar) compare against akka today. – agam Dec 24 '19 at 10:25
  • Sorry if that wasn't what you were looking for, but your comment about "one answer used to be agents", and from the answers I know of, Clojure agents were never the answer to how to program using the actor model, or at least not a correct answer. – andy_fingerhut Dec 25 '19 at 00:43