Nicolas Neu

dies & ditt.

Starting With Clojure

One item which has been on my todo list for quite time now is to fiddle around and learn a functional language of some sorts. Most programming I do nowadays is either in Python or Java with a little bit of Ruby or Javascript here and there. The parallel code I wrote was in C using OpenMP or MPI and while I admit that OpenMP can be pleasant to work with, I still wished for a nicer, more explicit way to accomplish my tasks. Functional programming languages are based on the idea of side-effect free programming (with some languages complying with this goal more than others). This allows the runtime to execute code in parallel without requiring the programmer to explicitly use concurrency constructs (Threads, Runnables, #pragma omp’s or whatever) in his code.

Another nice thing is that understanding the functional programming style helps you to write better code in general. At least that’s the word on the street and if I remember Blochs Effective Java correctly pretty much every second thing he said boiled down to: avoid side-effects, so it seems to be pretty legit.

I won’t give an introduction into Clojure per se, but I will showcase some resources that helped me to get started and made the process of learning the language a lot easier.

  • Programming Clojure by Emerick, Carper and Grand. A very extensive book which provides an easy to understand introduction as well as advanced topics.

  • Leiningen makes it easy to set up and maintain a Clojure environment on your machine. It also simplifies project management although I didn’t really come into contact with this functionality.

  • Light Table is an open source IDE with excellent Clojure support. Resolving the values of S-Expressions immediately after input and displaying the results makes it very easy to follow the program flow, even for more complex applications. As a Lisp novice who had a hard time parsing all those parentheses, this was a great help.

  • 4Clojure provides programming puzzles similar to Project Euler. The big difference is that the puzzles are designed to help you learn Clojure along the way. New concepts are introduced by presenting successively harder becoming problems you can solve in Clojure.

  • Multiple Videolectures addressing different Clojure related topics. They ranged from being very general, outlining the motivation behind Clojure to more technically focussed ones dealing with concurrency in Clojure: Hammock driven development, The Value of Values, Concurrency in Clojure.

  • ClojureDocs provides a nice API including examples for all the complete Clojure standard library. Unfortunately it is slightly outdated albeit this didn’t affect me too much.