Persistent immutable collections, structural sharing, and why this is practical on the JVM.
In Clojure, immutability is not “a best practice”. It is the default. When you “change” a vector or map, you get a new value back, and the old one is still valid.
The key idea that makes this practical is structural sharing: the new collection reuses most of the old collection’s structure instead of copying everything.
assoc, update, conj, dissoc to produce new values.Java mental model:
finalreferences and unmodifiable collections are optional in Java. In Clojure, “no in-place mutation” is built into the standard data structures.
Once you trust immutability, many other Clojure idioms become obvious: concurrency is safer, tests are simpler, and refactors have fewer hidden coupling points.