|
|
|
|
|
by spacemanaki
5405 days ago
|
|
You can still write pure functions even if they aren't enforced by static typing, right? What do you mean by "IO effects hidden behind seemingly innocuous evalation"? Clojure's data structures are immutable, and I don't think you're supposed to use STM with any mutable objects or data. You pass pure functions to the STM system that take an old (immutable) value and return a new (immutable) value. They are pure though, so they can be called multiple times in a transaction. I'm sure I'm making a muddle of it explaining it though, and I'm not sure what you concerns are specifically. So I highly recommend reading the ants.clj demo and watching the accompanying video with a detailed explanation by Rich Hickey, it helped me understand how STM works specifically in Clojure better than any other source, including two books on Clojure. I don't have experience with Haskell's or any other STM though, and I'm really just a novice with Clojure, so YMMV, etc. http://blip.tv/clojure/clojure-concurrency-819147 |
|
One of the nice things in Haskell is that effects are typed. So STM can require its given actions to only have STM effects, and disallow full-fledged IO effects.
If you're willing to go by convention without compiler guarantees, then I'm not sure what advantage Clojure has over Java here, as an example?