3 ms·
I've been developing in Clojure for a while now, and I think your characterisation of the role of pure functions in Clojure is somewhat inaccurate. In any give
by weavejester 12y ago
I've been developing in Clojure for a while now, and I think your characterisation of the role of pure functions in Clojure is somewhat inaccurate.
In any given Clojure code base, you'll be dealing with pure functions 95% to 100% of the time. Most of the libraries I've written are completely pure, not out of idealism, but because side-effects are simply not necessary.
Yes, Clojure provides tools to limit and constrain mutability, but if you've only recently come from an imperative language, you may be surprised at how little these tools are actually used. Most of the time you're dealing almost exclusively with pure functions, so tools to manage mutability are not necessary.
Discussion of pure functions is certainly idiomatic Clojure, because you'll be dealing them most of the time. Just because Clojure doesn't enforce purity through its type system, doesn't mean you shouldn't prefer pure functions the vast majority of the time.