3 ms·
"While we make heavy use of the core of Clojure, we don't use its concurrency primitives (atoms, refs, STM, etc.) because a function like pmap doesn't have enou
by jshen 15y ago
"While we make heavy use of the core of Clojure, we don't use its concurrency primitives (atoms, refs, STM, etc.) because a function like pmap doesn't have enough fine grained control for our needs. We opt instead to build our own concurrency abstractions in Clojure on top of the outstanding java.util.concurrent package."
I wrote a web crawler in clojure at at&t and our team came to this same conclusion. First we tried to implement a custom atom, but finally using java.util.concurrent directly.
I'm not sure what this says about the clojure concurrency features, but I've found myself using them sparingly even when doing a lot of concurrency.
- eternalban 15y agoRich Hickey is borderline genius in my book, and I really enjoy his philosophical approach to CS. Clojure is a fine language, but I frankly never bought the "concurrency issues" as a reasonable motivation for Clojure (over Java). Fact remains that STMs (as originally developed by the Scala team in (yes) Java), "outstanding" [OP] concurrency, and idempotent/functional programming remains /well within reach/ of the seasoned developer in Java. Also, unless I misunderstand their architecture (and it is single node ..), then the fact remains that in a distributed system, the "semantics" of interaction are not bound by the programming language behind box x, and are entirely a matter of the (remote) API you expose. STMs are a concern of a shared memory space -- once you go distributed, it is really borderline snakeoil to talk about the benefits of "functional" languages in creating remote functions.
- jshen 15y agoOur system was both distributed and highly concurrent in the same memory space. We started off using atoms, but we needed visibility and control over the queue feeding the thread for the atom which lead us to using java.util.concurrent directly. Our use case was fairly odd though.
- swannodette 15y agoFor people outside the community this may seem like a surprise. But Rich Hickey has been saying for a long time now that Clojure explicitly does not try to emulate many of the tools found in java.util.concurrent for the very reason that they are quite good.
- jshen 15y agoRight, and what makes me like clojure is the default of immutability. Even if I don't use their concurrency primitives heavily, the default to immutability makes writing concurrent code less scary.