4 ms·
In short: it is inconvenient to use mutable state and unidiomatic to not use the STM. The long version is that you could use 'set!' with Vars. But this is ver
by dgb23 7y ago
In short: it is inconvenient to use mutable state and unidiomatic to not use the STM.
The long version is that you could use 'set!' with Vars. But this is very much an avoided practice. Another caveat is that Clojure is hosted (primarily JVM and JS), so any code you call via interop has the characteristics of the host target.
But idiomatic Clojure uses at least Atoms or Refs and even those are discouraged for anything else than storing state, all the algorithmic (transformation, branching and so on) code follows the FP paradigm.
A Rust analogy is the 'unsafe' escape hatch. You can use it but it would be unidiomatic, inconvenient and in most cases unnecessary.
- fnord123 7y ago>Does Clojure actually force you to use those abstractions though? tl;dr: no
- dgb23 7y agoThat comment is somewhat disingenuous. It is like saying that Rust is an unsafe language, because of 'unsafe' or the mere fact that you can just use stringly types for everything. Both using 'unsafe' and using String instead of an Enum would compile without runtime guarantees. But such code would stick out.
- int_19h 7y agoIs STM still idiomatic in Clojure? I had the impression that it is considered kinda legacy at this point.