Getting Started with Clojure

Fellow Rubyists seem excited about learning Clojure.

If you’re still puzzled by this seemingly hipster language, I recommend you to watch the talk titled “You really should know a little bit of Clojure” below.

Ben Orenstein (@r00k) from ThoughtBot gave an excellent introduction to Clojure and also showcased some cool features of the language.

Ben explained how learning a functional programming language like Clojure can help Rubyists write better code.

Admittedly, I am completely sold.

One really impressive demo is on the Clojure macro system, which appears to be more superior than Ruby metaprogramming.

Enough sales pitch. Let’s get started.

Installation

We can download clojure.zip from the official Clojure website and follow the instruction to have the minimal install.

Instead, I installed Clojure via Leiningen which - as its homepage brags about - is “the easiest way to use Clojure”. To be precise, Leiningen is an extensible build tool for Clojure that provides dependency management, REPL support, testing, packaging, deployment, and many other capabilities.

However, I did not follow their installation instruction as I prefer Homebrew. Below are the steps that I did:-

Step 0: Install Java JDK version 6 or newer if you haven’t (http://www.oracle.com/technetwork/java/javase/downloads/index.html)

Step 0.5: Install Homebrew if you haven’t (http://brew.sh)

Step 0.9: Update Homebrew

brew update

Step 1: Install Leiningen

brew install leiningen

Step 2: Fire up REPL to test

lein repl

Congratulations, You have got Clojure up and running!

To learn the basics, work through Try Clojure (http://www.tryclj.com)

After that, work through Brave Clojure (http://www.braveclojure.com). I can’t recommend it enough.

Many Clojure experts favor Emacs but I use Vim. Gabe Hollombe (@gabehollombe) from Neo wrote an excellent post on how to “Use Clojure in Vim” (http://www.neo.com/2014/02/25/getting-started-with-clojure-in-vim)

Have fun learning Clojure <3 <3 <3