A couple of points of order before I start the essay:
Office Hours
You can join my weekly office hours, where I answer any and all questions. It’s live and unprepared. Just hop on the Zoom call at the right time and ask your question. If you don't have a question, you can watch the stream on YouTube.
Details
Two rules:
Only join the Zoom if you have a question ready. You’ll start in the waiting room, and I’ll let you in when I’m ready.
You agree that it can be broadcast live and be available on YouTube to watch later.
Domain Modeling Breakdowns
Do you have a domain and want to model it, but you’d like some help? I can help—for free! You can be one of the first!
Reply to this email with a brief (3-5 sentence) description of the domain and what kind of model you’ve got. Then, we’ll schedule a Zoom call, which I will record and publish to YouTube. We’ll explore how best to encode the domain on the call.
Now for the essay:
What I like about Clojure
I used to try to sell Clojure on its features: concurrency by default and JVM ecosystem. Then, I tried to sell it on its practicality: more done in less time. I even tried to sell Clojure on its philosophy: simplicity and solving real problems. But now I speak from the heart. I say why I like it. I like Clojure because it hits a sweet spot between feeling straightforward and teaching me.
When I first started getting into Clojure, many decisions Rich Hickey made felt right. I knew Java and Common Lisp. Clojure made seq
an interface instead of a Common Lisp/Scheme cons
data structure, and that made sense on the JVM platform. seq
is more useful than a cons
, and it improved on Java iterators. It bridges the lispy map
/filter
/reduce
style and the Java platform.
As I learned more about the language, I had many similar insights. They seemed like great design decisions for a language I liked (Lisp) on a platform I knew (JVM). They were insights I wouldn’t have had myself, yet once I saw them, I could internalize them. Using Clojure taught me about design, tradeoffs, and abstraction.
The insights continued into the standard library. There were so many functions that I wish I had had years earlier. Take frequencies
for example. It counts the elements in a collection and returns the counts in a hash map. That function is so useful! Counting things is so common in algorithms. I have written so many for loops to count things. Yet I had never written the general-purpose frequencies
. Not only was it super useful, but it was also easy to implement. When coding in another language, I often write frequencies
as part of an algorithm, and the result is better than without it. Clojure wasn’t just teaching me Clojure; it was teaching me to code in other languages!
This same process extended well beyond the standard library. My editor for Grokking Simplicity was very surprised that in chapter 16, I built a queue in JavaScript. “Why not?” I said. “We needed a queue. JavaScript doesn’t have one. So I built it.” He was even more surprised by that attitude. “Most people would go searching for a library,” he said. Not being seeped in the JS world, I was astonished: “But it’s 24 lines of code!”
We discussed where this DIY attitude came from. It was Clojure. Clojure taught me the value of generic, reusable abstractions. Clojure taught me how to decompose problems. Clojure taught me that you can build things yourself with the right tools—and often, you can build the tools yourself. Clojure has led me, step-by-step, to the confidence and competence to build the things I need.
Other languages have taught me, too. I still have a fondness for C, which taught me the art of pointers, memory management, and optimization. I also learned to appreciate that its simplicity is the source of its power. Haskell taught me case analysis and careful modeling. Doing over-complicated things in it requires complicated code. It can teach you restraint and respect for powerful abstractions if you let it.
Of course, this is a personal story. There are people with bigger brains than me and people with smaller ones. An insightful abstraction to me might be trivial or incomprehensible to others, depending on their capability. And we all have our histories. Mine taught me Common Lisp and Java, and Clojure brought them together. The point is that falling in love with a language is a personal journey. It depends on where you are when you find the language and your innate proclivities. But every step I took with Clojure was filled with insights. I hope everyone can find a language that gives them the richness that Clojure has given me.