12 ms·
Surprised that a thread about CSP in Lisp doesn't mention Clojure's core.async. CSP in Clojure is implemented as just another library and it's rock solid. While
by oskarth 10y ago
Surprised that a thread about CSP in Lisp doesn't mention Clojure's core.async. CSP in Clojure is implemented as just another library and it's rock solid. While I don't claim to understand the implementation in detail, it's one of the more interesting and high leverage uses of macros I've seen in Clojure. It makes concurrent programming a breeze in Clojurescript as well, despite JS being single-threaded.
As someone who programs in both Clojure and Go there's absolutely nothing I miss from CSP in Go, and I would much rather do concurrent programming in Clojure.
Rationale: http://clojure.com/blog/2013/06/28/clojure-core-async-channels.html http://clojure.com/blog/2013/06/28/clojure-core-async-channe...
Code: https://github.com/clojure/core.async/blob/master/examples/walkthrough.clj https://github.com/clojure/core.async/blob/master/examples/w...
Presentations: https://github.com/clojure/core.async#presentations https://github.com/clojure/core.async#presentations
- jgalt212 10y agoAs 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).
- stewbrew 10y agoWhy should an article about common lisp mention a clojure library? Because of the parentheses?
- mateuszf 10y agoBecause of CSP
- codr4life 10y agoThe reason, sadly; is that I lack experience with clojure.async, I lost my motivation before I got there; a couple of years ago it was still too experimental for my taste, didn't offer enough advantages over CL, lacked fundamentals like error handling and was tied to the mountain of complexity called JVM.
- oskarth 10y agoTo clarify, I meant this thread on HN when I said thread. I don't find it strange at all that that your article didn't mention it. Thank you for writing it!