Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



Is STM still idiomatic in Clojure? I had the impression that it is considered kinda legacy at this point.


>Does Clojure actually force you to use those abstractions though?

tl;dr: no


That 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: