How to earn your Clojure white belt

I tend to think that if I do not know how to implement something then I do not undestand completely how it works. That is why I want to…

How to earn your Clojure white belt

I tend to think that if I do not know how to implement something then I do not undestand completely how it works. That is why I want to learn so many things: new frameworks, programming languages, garbage collectors, type systems, compilers, editors, operating systems, protocols, kernel development. The road to enlightenment is long and difficult. To make things worse, you need to invest time on keeping up to date with technologies you thought you already knew. I usually feel like Mario in one of those levels where he needs to jump between moving clouds to reach the finish line.

That is why one of the best skills to get is being able to separate the wheat from the chaff. We have finite time and distractions are infinite. If you are going to invest time in learning a new language then you should consider Lisp which is definitely wheat of the best quality. If you don’t know why, then go read Beating the Averages article. Clojure is a member of the Lisp family. If you have used a Lisp dialect such as Scheme, Common Lisp, Emacs Lisp, or even really alien and amazing creatures such Shen, LFE, Racket, Pixie you might ask yourself why you should be learning Clojure. This is my opinionated point of view:

  • The language’s creator: Rich Hickey has a holistic understanding of this era development issues. You should read/watch his talks called Are We There Yet?, Simple Made Easy, The Language of the System. I see Clojure as a step in the right direction for tackling this era’s development issues
  • Great functional programming support: First class functions, persistent, immutable data structures and lazy sequences. It has great support of polimorphism thanks to multimethods and protocols
  • Concurrency support from its inception thanks to atoms, agents, refs, a software transactional memory system and asynchronous programming using channels a la CSP with core.async library
  • Batteries included: good core libraries and transducers support
  • Clojurescript: Clojure that targets JavaScript with great libraries such as reagent, an interface to React.js that is really simple and useful. Check David Nolen’s talks called ClojureScript: Lisp’s Revenge and Introduction to ClojureScript
  • JVM’s power (available almost everyhwere, optimized garbage collector, JIT compilation, Java interoperability), but also some issues such as not being able to properly support tail call optimization and awful stacktraces. If you are a Java developer you should check part I and II from Rich Hickey’s Clojure for Java Programmers talk

Ready, steady, go!

Install Leiningen and configure your editor of choice.

Good tools that deserve a mention

Love at first sight

First of all get an idea of Clojure syntax and semantics:

  1. Learn X in Y minutes where X=clojure
  2. Clojure by example
  3. How I start Clojure
  4. Listen to Software Engineering Radio’s interview with Rich Hickey

If you do not understand something move on. At this stage the only objective is to grasp some basic ideas about Clojure.

Practice plus reading equals perfection

  1. First practice with the Koans
  2. Then read Clojure for the Brave and True, a simple and short book. If you prefer to watch videos, you can buy the course Introduction to Clojure from PurelyFunctionalTV.
  3. Practice again with 4clojure problems
  4. Follow the road to perfection with Clojure exercism
  5. Finish the practice with Wanderland Clojure Katas

It is always a good idea to have the cheatsheet at hand.

Other two good tutorials worth mentioning are Clojure from the ground up and Hitchhiker’s Guide to Clojure.

Idiomatic Clojure

Clojure is not Java, neither Common Lisp or Scheme. You should learn to write idiomatic Clojure. The Joy of Clojure is your best friend to become a native Clojure speaker:

About The Joy of Clojure
When this book was conceived, our first instinct was to create a comprehensive com- parison between Clojure and its…

It is also important to follow table manners or the Clojure style guide.

If you have trouble like me grasping macros, then you should also check out Mastering Clojure Macros.

Oh, if you miss your type checking then now it is a good time that you read about optional type system for Clojure.

Keep up to date

Know the full arsenal at your disposal

Get help

Introduction to Clojurescript

Clojure on the frontend trench:

  1. Quickstart
  2. Differences from Clojure
  3. A series of tutorials on Clojurescript

Building your own Lisp

Building a Lisp is similar to a road trip with friends and good music but with no particular destination. Make yourself comfortable and enjoy the ride!


Did you like it? You can follow me on Twitter — @unbalancedparen