Which Clojure codebases should I read? How and why?

Newcomers to Clojure so frequently ask this question that an FAQ/Guide is being discussed, to add to the Clojure website. See Issue #586: Add FAQ or guide for example projects. Please add your thoughts to that ticket!

This post is my (opinionated) take on it. I struggled a lot with this too. I still do from time to time, in unfamiliar territory, and these days I feel like I’m in unfamiliar territory a lot. Various Clojurians — individuals and groups — have been producing so much creative, diverse work over these last few years that keeping up quickly became impossible!

No doubt this surfeit of creativity intimidates newcomers. The strange ideas, lingo, thinking, and writing espoused by Clojurians can seem so very alien. But despair not, for Clojureland also has a surfeit of friendly, helpful people. And very many of our codebases are small! You will be able to read them! And get help if you get stuck!

This post explains what I believe I’ve done subconsciously over the years. It is as much an answer for somewhat experienced me as it is for the relative newcomer you!

Read more →

n ways to FizzBuzz in Clojure

FizzBuzz is everywhere. Every programmer passes through its rite of passage, or at least bears witness to another. Over the years, many gentlenerds have taken it upon themselves to discover ever new ways to incant those hoary symbols.

I hereby enjoin these few drops of Clojure to that roiling ocean of FizzBuzzery.

The brainwave here is to (mis)use the feature set of Clojure and its standard library to cook up as many ways to encode FizzBuzz as one can muster (or steal). If all goes well, this post will receive many updates. If it goes really well, all sorts of bad ideas and clever foot-guns will be discovered and used.

The creative constraint is this: any FizzBuzz, however terrible or hilarious, must also be useful. It should have reason to exist and should reveal some real-world Clojure thinking.

That means no FizzBuzzEnterpriseEdition but also no Dylan Beattie’s brilliant FizzBuzz in RockStar. So sorry!

Read more →

Dismal Arithmetic in Dyalog APL and Clojure

Throwback: Jan 2018.

I learned of Dismal Arithmetic from @rdivyanshu who posed it as a programming problem in a Slackroom of local gentlenerds.

As the linked paper describes it:

Dismal arithmetic is just like the arithmetic you learned in school, only simpler: there are no carries, when you add digits you just take the largest, and when you multiply digits you take the smallest. This paper studies basic number theory in this world, including analogues of the primes, number of divisors, sum of divisors, and the partition function.

I thought it might be fun to implement it in APL for kicks, but I wrote it in Clojure first, because I wasn’t sure of my APL-fu. And I’m glad I wrote the Dyalog APL version because I learned something about trains, and also because I stumbled on the idea of “inverse of a function” which melted my mind a bit.

Read more →