[HN Gopher] Analyzing Every Clojure Project on GitHub
       ___________________________________________________________________
        
       Analyzing Every Clojure Project on GitHub
        
       Author : jjwiseman
       Score  : 59 points
       Date   : 2022-09-06 20:39 UTC (1 days ago)
        
 (HTM) web link (blog.phronemophobic.com)
 (TXT) w3m dump (blog.phronemophobic.com)
        
       | lukev wrote:
       | > 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.
        
       | stcredzero wrote:
       | _I 'm generally interested in tools like cljdoc that work at the
       | ecosystem level._
       | 
       | Isn't the meta-lesson of the history of programming languages
       | from the past 60 years, basically that _great language design
       | should take into account the ecosystem level?_
       | 
       | The success or failure of a language has really depended on the
       | health of its interaction with its community and ecosystems, much
       | more so than narrow technical merit of the language.
       | 
       | Name a language, and its history bears this out. (Clojure as
       | well.)
        
       | stanislavb wrote:
       | If you are interested, you can discover the most popular clojure
       | projects (by number of mentions) on LibHunt
       | https://www.libhunt.com/l/clojure. As most of us could expect,
       | Logseq is amongst the most popular and most trending projects.
        
       | bm3719 wrote:
       | Nice to see the data confirm the general consensus (by my
       | measure, at least) regarding the Clojure STM options.
       | 
       | Like others, I've been telling Clojure newbies something like:
       | When you need Clojure STM, default to using an atom unless you
       | really know you need to use something else.
        
         | [deleted]
        
         | capableweb wrote:
         | I feel like sometimes even `atom` gets over-used. When
         | explaining to newbies, maybe we can say:
         | 
         | > When you need Clojure STM, you usually don't, there is
         | usually another way. But if you really, really do need it,
         | default to using an atom unless you really know you need to use
         | something else.
        
           | robto wrote:
           | There's a handy chart in "The Joy of Clojure" that I refer to
           | whenever I'm trying to tackle concurrency problems:
           | |              | ref | agent | atom | var |         |
           | coordinated  | x   |       |      |     |         |
           | asynchronous |     | x     |      |     |         | retriable
           | | x   |       | x    |     |         | thread-local |     |
           | |      | x   |
           | 
           | Turns out I have never needed coordinated, synchronous stuff.
           | I have dabbled with agents, but just for an Advent of Code
           | problem.
           | 
           | I do like that 63% (!!) of clojure repos have no mutable
           | references at all - that tracks very strongly with my
           | experience. And that the average number of mutable references
           | is less than 2! Immutability can carry you a long ways, and I
           | love that I can trust that contract. On the other hand, it's
           | nice that I can opt in to mutation really easily if I need
           | it.
        
       | hospitalJail wrote:
       | Just mentioning, these are public projects on Github. Both my big
       | corp job uses github privately and I personally use it privately.
       | 
       | I wonder how that would skew things.
        
       ___________________________________________________________________
       (page generated 2022-09-07 23:01 UTC)