Hey! I’m James and I’m going to be learning Clojure this month

(? “Why learn Clojure”)

I’ve recently found myself “fun-employed” through my own choosing going into 2023. This is the first time in a while I haven’t had a critical, all consuming project breathing down my neck in many years and want to spend some time learning a new paradigm while also experimenting in public (a little).

Clojure itself seems to be frequently hailed as a mind-bending, unique, and amazing language by a lot of people I respect and some people who get lots of fake internet points on hackernews.

If you want to try Clojure quickly you can use this site to do so purely online

Who are you

At present I’m your average developer that works primarily in the API development/DevOps development space for early stage startups building complex web applications in the workflow/automation space.

While I primarily work in Typescript for application development I also have a decent bit of experience across functional (Scala), imperative (Typescript, Go, Rust), and Object Oriented (Typescript, Java, Ruby) development professionally.

What this is not

This series will probably not teach you Clojure. It’s going to be a bit more of a look into how I learn new concepts and what mistakes I make since I’ve been told I am a “voracious learner”.

Also I’m currently on holidays for December so I probably won’t even be posting an update for every day of the month!

Day One:

Step One: Assumptions about Clojure and what I want to learn

First I’ll define what it is that I want to learn and what I think Clojure is. This is always interesting to look back on in a few years time and see what was marketing and what really was revolutionary about any new piece of tech I learn.

  1. I will (probably) never find a job that uses Clojure. 0 jobs in Australia when I checked.
  2. Tooling will probably not be very easy to use/mature relative to Go/Typescript
  3. Clojure will probably be very slow to start and very memory heavy (JVM is the primary target)
  4. I will probably find the lack of static types to be infuriating. I haven’t touched a language without static types in a pretty long time since I hate refactoring others code in purely dynamic languages.
  5. The idea of editing production applications live from a REPL sounds like some horrific callback to a production Rails console and I don’t think I’ll approve.
  6. Clojure will likely improve the way I structure/write code because of:
  7. REPL driven development and an even faster iteration cycle
  8. Deeper exposure to data-oriented programming

Data oriented programming is of particular interest to me when architecting new web platforms. I frequently see issues arise from interspersing what should be configuration/data as hard coded values between class names, constants, and otherwise things that should be inputs to a program instead of the program itself.

Official docs are the first thing I skim

I like to be exposed to as many new terms/phrases as possible without understanding them so that I can build up a “terminology backlog” that I’ll figure out as I follow more structured resources.

Some terms/words I see mentioned I don’t immediately understand:

  1. Form
  2. Leiningen
  3. Lisp. What is a lisp. I thought this was a language(?)
  4. nREPL. Is this a protocol?

Clojure for the Brave and True by Daniel Higginbotham

This seems to be listed as the best book to learn Clojure after a few Google searches. I’ll typically read the first couple chapters linearly then I’ll skip around the chapters that mention something I didn’t understand from my (still growing) terminology backlog.

Books also typically are the easiest way to understand what tooling you’ll need.

In this case I only needed Leiningen and a JDK. On arch I just run sudo pacman -S leiningen to install the the preferred clojure compiler for the JVM.

Using lein I can now initialize a project and run it

lein new app clojure-noob
cd clojure-noob
lein run

I can also package and “deploy” an uberjar pretty easily with Clojure.

lein uberjar
java -jar target/default+uberjar/clojure-noob-0.1.0-SNAPSHOT-standalone.jar

Now that I have my first Clojure file in a .clj file I can start trying to change things in the code until something breaks or I learn something new.

The lein repl command took forever to boot initially (20 seconds?) but I was able to interactively write some clojure quickly.

IDE Setup (Vim)

At this point I need to set up my own development environment as well. While most people I know just install an extension there’s a bit more research to be done when your primary IDE is Vim.

I found the plugins conjure and coc-conjure which hook into an existing Clojure nREPL instance and seem to give me some limited autocomplete/documentation which is helpful when discovering language features.

I still need autoformatting, test running, and better documentation support in Vim but I’m happy with where I am for day 1 IDE setup.

Finally

I spent several hours in the Lein REPL and learned the basics of Clojure functions/variables without reading too much actual docs by reading some random Clojure projects on Github.

Tomorrow I’ll focus more on formalizing my understanding of expressions, clarifying my open questions and making something actually useful.