by lukev · 4y ago · 0 comments
> Repositories with no mutable reference usages: 7,245 (63%)
> Truly bananas. Clojure libraries really do have less state. It probably isn't surprising if you've been programming in clojure for any length of time, but it's pretty wild to see the data back this up. I don't think I would have believed this 10 years ago.
Truly interesting and impressive, although I'll note that there are plenty of ways (most of them via Java interop) to introduce mutability of some kind into a Clojure program besides the first-class reference types (atoms/refs/agents/volatiles.)
I'd be interested in an analysis in what percentage of Clojure functions are truly referentially transparent, but that's difficult (if not impossible) to determine statically.
Fair point, I tried to word that statistic accurately without being too verbose.
> I'd be interested in an analysis in what percentage of Clojure functions are truly referentially transparent, but that's difficult (if not impossible) to determine statically.
Absolutely, I'm not sure it's possible or even practical to measure functional purity in an absolute sense, but there's definitely room for improvement:
- measure Java Interop
- measure usage of mutation functions (eg. swap!, set!, binding, send, vswap!, alter, etc)
- measure (def ^:dynamic *my-var*) usages
My intuition is that the numbers wouldn't change that much, but I'd rather have the data than guess.