My Profile Photo

Bits and pieces

Between bits and bytes and all other pieces.
A tech blog about Clojure, BigData, and Software Architecture.

Clojure pills: Getting started

To get started with Clojure, you need the REPL. The REPL stands for Read Evaluate Print Loop and it is a console-like application where you can enter Clojure functions/expressions and get the result directly.

This is the best and simplest way to explore the language as you won’t need to setup and IDE and go through a edit/compile/run cycle. The REPL looks like an interpreter, however Clojure is NOT interpreted but compiled. The compilation will happen behind the scene without you noticing.

The easiest way to play with Clojure REPL without commitment is to use the online REPL:

The second possibility is to download Clojure from In this case you’ll need few more steps:

$ # donwload
$ unzip clojure-*.zip
$ cd clojure-*
$ java -jar clojure-*.jar
Clojure 1.5.1

When the user=> prompt appears you are in the REPL.

However, if you are serious about learning Clojure, I’ll suggest to use Leiningen. It’s a build/automation tools such as Maven for java. To install Leiningen follow those steps:

$ mkdir -p ~/bin
$ wget "" -O ~/bin/lein
$ chmod +x ~/bin/lein
$ # ensure it is in the PATH
$ export PATH=~/bin:$PATH

$ lein new try-clojure
$ cd try-clojure

$ # you can see the project descriptor file
$ # and change the Clojure version to the one of your choice
$ vi project.clj
(defproject try-clojure "0.1.0-SNAPSHOT"
 :description "FIXME: write description"
 :url ""
 :license {:name "Eclipse Public License"
 :url ""}
 :dependencies [[org.clojure/clojure "1.5.1"]])

$ # finally you can run the REPL
$ lein repl
Clojure hello world!:

In the REPL of your choice you can evaluate your first function:

user=> (println "Hello world!")
Hello world!
comments powered by Disqus