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

> Average mutable reference usage per repository: 1.94

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



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

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.


lazy seqs are not RT so ~zero


If your lazy seqs contain side effects that are evaluated as the seq is evaluated then definitely not RT (and this is a pretty big no-no in Clojure to begin with). Otherwise, it seems like lazy seqs are RT in the sense usually used by programming languages. Otherwise a language like Haskell wouldn't have anything considered RT.


also exceptions and dynamic scope




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

Search: