Learning Clojure

A couple weeks back, I had a random thought: what are the commands I run the most frequently, and how frequently do I run them? Naturally, I had to scratch this itch, and since I've been exploring Clojure lately, it seemed like the perfect opportunity to put it to use. I'm no stranger to functional programming, having first been exposed to its concepts in Kotlin and solidyfing my comfort with it in Haskell, so I actually found it pretty easy to express my ideas in Clojure and get to a working solution pretty quickly. I did fumble around a bit with the lisp syntax though. Like Rich Hickey joked in his talk Simple Made Easy1, "I've seen parens before but never on that side of the function name". Coming from Kotlin, I found the compiler errors in Clojure to be rather unhelpful in most cases, because usually I was just forgetting to wrap my functions in parens or something silly that I would think would have been an obvious syntax error that the compiler would easily point out. This was not the case, however, and in some cases I could even get the program to compile and run but just not do anything, which confused me even further. I imagine that basic syntax errors are things I could easily spot with more experience though so that probably wouldn't be an issue in the long run. I also found myself getting used to the lisp syntax pretty quickly. I actually appreciate some aspects of it and maybe it's just the novelty of it but I could see myself coming around to actually preferring it.

Once I got my idea translated into code and running, I was pretty disappointed with the run time, at just around a second for a pretty basic loop over just 1000 of my most recent shell commands. I knew this had to be mostly because of the JVM, so I made the effort to build it with GraalVM and sure enough, the run time came down to 4ms, much more in line with my expectations. 1 second is really not a huge deal but even slower scripting languages can usually perform similar tasks in sub-second times so it felt unreasonably slow. I don't love needing to lean on GraalVM to get better performance like this though, so I ended up rewriting it in Haskell.

My experience with the Haskell rewrite was surprisingly not much better, despite having far more experience with Haskell than with Clojure. I've been writing Haskell off and on for nearly a year at this point, and yet I found myself stumbling through the implementation, mostly getting tripped up on the IO monad and getting my type definitions just right. If you were to ask me, I'd say that I vastly prefer strongly-typed programming languages and even hold Haskell's purity in high regard, but in practice I'm no longer sure how true that is. Ultimately what it comes down to is I find myself having less and less time to work on personal projects the older I get, and in the past I tended to stick with languages that I used at work because I was far more productive in them. Unfortunately for me, that would mean doing everything in Kotlin, which all but necessitates that I use IntelliJ, which I'm not a huge fan of. So, when looking at Haskell code, even Haskell code that I wrote myself a few months back, I find it somewhat difficult to understand what's going on. Maybe it's because I've spent the past decade in the JVM world where verbosity is the norm, but Haskell is maybe a bit too concise for my taste. To Haskell's credit though, my reimplementation ran in 2ms with no extra optimization work on my part. Like I wrote previously2 though, I doubt I'll see myself becoming a Haskeller because the language just doesn't quite sit well with me. I think it's far too complex for my needs.

Some time later, I ran across babashka, a script-like runtime for Clojure that has instant startup time. Babashka unfortunately seems to welcome AI contributions, so I'm not thrilled about that, though I suppose I could always just stick with an older version of it. With babashka, I can get my small Clojure program to run as a script in 20ms, which is perfectly acceptable to me. Curiously enough, despite Clojure having much of the same drawbacks that I wrote about Haskell in my previous post 2, I do actually see myself writing more of it. The AI landscape has changed my opinion on the employability of using a programming language, and Clojure gives me access to the JVM, so I can cheat and use mutable data structures as an escape hatch if I find that the pure functional approach is too cumbersome or slow. Above all though I really appreciate Clojure's simplicity. It feels like the Go of the functional world, another language I greatly admire and enjoy using because of its simplicity. Simple software is just easier to maintain, and using simple languages facilitates writing simple code.


  1. https://www.youtube.com/watch?v=SxdOUGdseq4 ↩

  2. https://wbrawner.com/2025/06/22/learning-haskell/ ↩↩