38 ms·
As I understand it, there are multiple ways to do concurrency in Clojure. Is there a best way or a way that fits most use cases so that you should at least try
by jgalt212 10y ago
As I understand it, there are multiple ways to do concurrency in Clojure. Is there a best way or a way that fits most use cases so that you should at least try feature X before features Y, Z, and/or roll your own?
- deleted 10y ago[deleted]
- deleted 10y ago[deleted]
- nickik 10y agoThere is no easy path you can follow sadly. It depends on your use case quite a bit. Clojure gives you a lot of options and you have to find your own way. What Clojure gives you by default, are thread safe mutation constructs, atoms, agents and refs that help a lot if you want to do simply concurrent things without worrying about race conditions. Clojure also has support to get some data parallelism, you can easily do a lot with reducers and transducers. Its quite nice. For more complex stuff, core.async gives you a powerful CSP library, its as powerful as what the Go programming language gives you (I think its nicer because Go has statements instead of expressions). Because Clojure is on the JVM, you get access to all the Java stuff, java.util.conncurrent, and you can get a lot of powerful tools there (ThreadPools and stuff like that).