Nick George
all/

Why Clojure?

First published: September 8, 2018
Last updated: January 8, 2023

I am currently learning Clojure, mostly because I wanted to learn functional programming principles and Rich Hickey gives amazing talks, but also because it is a functional programming-focused lisp dialect that can be hosted both on the web with ClojureScript (via compiling to optimized JavaScript) and the on the JVM (via Clojure). It is hard to articulate why I think this language is so cool, but I will try to explore that in the post below.

Why not just learn JavaScript?  ¶

You can do the same thing with JavaScript and NodeJS– right? Cross-platform apps and all the power of the web. Well yeah, kind of, but I don't really want to learn JavaScript. This is partly because I have limited time, but the real reason is that JavaScript doesn't seem to offer any interesting new paradigms or ideas apart from what I already know from Python and R. All I get from learning JavaScript would be a new syntax and more of the same headaches (and apparently a lot of new ones– see Gary Bernhardt's wat and the birth and death of javascript).

Leverage, new paradigms, and a rich ecosystem  ¶

Compared to JavaScript (or really any other language I have seen) Clojure appears to be an extremely well thought out language that allows me to explore the world of Lisp and functional programming with immutable data structures. The icing on the cake is that Clojure can compile to and leverage all of JavaScript with ClojureScript. Note: I think this figwheel for ClojureScript development demo by Bruce Hauman is reason alone to learn Clojure(Script)! By learning Clojure, I get a lot more leverage (all of the JVM, Lisp, functional programming, and web programming/JavaScript) than I would get from any other language I know of.

Learning a craft rather than getting a thing  ¶

A lot of people learn a programming language to use or get a thing. Python has pandas for data, django for websites, and many more tools that people come to the language specifically to learn. Similarly, R has the tidyverse, and Ruby has rails (I know they all have a lot more to offer too, but I don't use them as much). JavaScript has the web, single page apps on the web and desktop via NodeJS (definitely a huge deal and very important). Huge communities build up in the languages around those features and the languages become richer and more popular because of it. There is really nothing wrong with this. I learned Python and R reasonably well, for the data analysis and automation I need to do for my work, but– I am not a professional programmer.

Programming and building software is my favorite hobby, and I use it a lot in my scientific work. But I am not currently being paid anything to write or learn code. This makes me a little lucky in that it frees me up to pick what I want to learn based purely on how much value I think it brings to the table and how much enjoyment it brings me to use it, rather than based on what my company uses or whatever is popular now.

A lot of thought went into the design of Clojure and it has a lot of power behind it (immutable persistent data structures and all of the JVM ecosystem among other things). It is not exactly simple or intuitive when you first pick it up like Python is, but the reality is that most skills worth learning require a lot of time and effort to acquire. Rich Hickey articulated this point well in one of my favorite talks when he said: "Musical instruments are not made for beginners". He explains instruments are made for professionals because you are only a beginner for a really short period of time, and a designed-for-beginners thing is inevitably going to impose simplifications that will limit the flexibility or power of it as you inevitably improve. There is not a shortcut for becoming an excellent piano player, but there is also no limit to the depth and complexity of the music you can create with that instrument. I am not a musician, but I love writing code so any language that gives me the kind of leverage that Clojure does is definitely worth my time.

A lot of cool stuff has been written about the power of the Lisp programming paradigm as well. One of my favorite essays is "The Lisp Curse" by Rudolf Winestock (http://www.winestockwebdesign.com/Essays/Lisp_Curse.html). If that doesn't inspire you to learn Lisp then I don't know what will. A bit cliche, but Paul Graham's essay also drove this point home http://www.paulgraham.com/avg.html.

Everything I have read about the amount of time and thought put into designing the Clojure language and the amount of power you get from lisps in general makes this an extremely attractive language to learn. By learning Clojure I'm not getting a big, flashy car or an expensive power tool. I am getting a set of extremely versatile, battle hardened hand tools (another of my favorite talks is Tim Ewald's Programming with Hand Tools https://www.youtube.com/watch?v=ShEez0JkOFw). As Tim Ewald explains in that video, with those hand tools I can do anything you can do with your power tools, but I will have a much deeper understanding and appreciation for what I am doing and I will be making things simpler and likely a lot more reliable, as opposed to gluing big complicated junk together.

I want to build tools that help me do my work and will hopefully be useful to others, and I want to enjoy doing it. Python is great for this– it was my first real programming language and will always hold a special place in my heart and toolbox. But Clojure is my current interest and the more I learn and practice the more I can do, the more I understand, and the more I love this tool.

Favorite Clojure talks  ¶

The talks below have had a big influence on me. I learned a lot from them and return to them often.