Clojure in 3 Minutes
There are a few different ways to install and configure Clojure. I was shown this way, which seems to be the easiest, most straightforward way of getting Clojure up and running. I’m pretty sure it’s the most straightforward way that I’ve seen of getting any language up and running. Stick with me and you’ll have written your first line of Clojure locally within 3 minutes. Five at the most.
We’re going to use Leiningen to get Clojure installed and running. Taken from the readme file:
Leiningen is for automating Clojure projects without setting your hair on fire.
Working on Clojure projects with tools designed for Java can be an exercise in frustration. With Leiningen, you just write Clojure.
Disclaimer: I’ve only done this on OS X and Linux, but the process should be as straightforward on Windows.
Start the timer. If you care to play along, post a comment when you’re done with your total time from installation to writing line of Clojure and seeing it run.
Before getting started, you should be familiar with your $PATH environment variable. You’ll be downloading a file, and you’ll want to save it to a location that’s currently in the $PATH. If you’re on OS X or Linux, you can type echo $PATH into a terminal window to see what locations already exist on the PATH. On Windows, the process may vary slightly depending on whether or not you’re running XP or Vista or Windows 7.
OS X and Linux:
- Download the script. Save it as a file named
lein. - Make the file executable:
chmod +x lein.
Windows:
- Download the Windows Distribution.
- Unzip into a folder that exists in your $PATH.
You might be wondering what step 3 is, because surely it can’t be that simple. Assuming that you’ve got Leiningen set up in a location that’s accessible to your PATH environment variable, it’s that simple.
From a terminal window or command prompt, type the following: lein repl. Since this is the first time you’re firing up Leiningen, there will be a short pause as the necessary Clojure files are downloaded. This should only occur during this initial run. Within a few seconds, you should see:

You’ve now got a REPL, a Read-Evaluate-Print Loop, and a convenient place to write yourself some Clojure. At the prompt, type the following:
(println "Hello, World. I know Clojure!")
Hit enter, and you should see:

Congratulations! You’ve written and executed your first line of Clojure. Was that 3 minutes?
12 comments | 2,817 views


RobG
More than 3 minutes, but ONLY because my ‘net connection is pretty slow right now. It took about six minutes just to do the download, but the rest was ridiculously simple. Now I can figure out what all this clojure talk is about.
Good job!
Clojure in 3 Minutes | Clojure | Scoop.it
[...] Clojure in 3 Minutes Figuring it out as I go (RT @kumarshantanu: #Clojure in 3 Minutes @ Charlie Griefer http://j.mp/nok4Ss…)… Source: charlie.griefer.com [...]
Frank Priscoglio
way too easy, under 3 mins for in Ubuntu! Looking forward to this series
GeekyCoder
The best development experience for clojure is to use the Intellij IDE which provides superior support for the language with features like color-coding, auto-format, auto-complete, superior code editing, parameter list etc.
You can use the free Community edition of Intellij (http://www.jetbrains.com/idea/download/index.html) , and then install the clojure plug-in from the Settings Screen. Create new Project, and then activate the Clojure REPL within the IDE.
You can see how the environment support the Clojure here
http://yfrog.com/z/klyyqop
Charlie
Oooh, I like that. I’d been using Eclipse and the CounterClockwise plugin, but I’m really not a big fan of Eclipse in general. I’ve found that it can be quite the resource hog.
Wondered what others were using for their Clojure IDE. Will definitely check that out.
Jamie Krug
Yup, that setup took nearly a full minute
Thanks Charlie. I upgraded my main laptop distro to Linux Mint Debian Edition (XFCE) recently, so I had to setup Leinengen once again. The Debian (testing) repos have an older version of Leinengen/Clojure, so I like this “manual” method anyhow. In fact, you could cut it down to about 3 seconds with the following one-liner, for most Linux desktop peeps (just run command as local user from the directory you’d like to hold the lein script):
wget –output-document lein “https://github.com/technomancy/leiningen/raw/stable/bin/lein” && chmod +x lein && sudo ln -s ./lein /usr/local/bin/
The /usr/local/bin/ directory is already on the PATH for most (all?) distros, so I just throw a symlink there pointing to wherever the lein script wants to live.
Cheers,
Jamie
Jamie Krug
Doh! Sorry, typed too quick, without testing… that symlink command won’t work. I also noticed that your blog converted double-quotes to some fancy quotes characters, and it also converted the two hyphens before “output-document” to an m-dash, so that really won’t work at all for folks trying a copy/paste into a terminal
If you allow PRE tags in this comment, then maybe this will work (but check closely if you copy/paste):
wget --output-document=lein "https://github.com/technomancy/leiningen/raw/stable/bin/lein" && chmod +x lein && sudo ln -s "$(pwd)/lein" /usr/local/bin/Charlie
@Jamie: The comments allow <code> tags. I’ve gone ahead and wrapped your code accordingly.
I’ll try to find some time this weekend to maybe add one of those “allowed tags” lists under the comment entry textarea.
Jamie Krug
@Charlie: Cool, thanks. FWIW, I just remembered that wget might not be a default available commands on Macs, but I believe curl is common to Mac as well as many Linux distros. So, this one-liner (using the code tag this time), I _believe_, will work for most all Mac and Linux users…
curl "https://github.com/technomancy/leiningen/raw/stable/bin/lein" -L -o "lein" && chmod +x lein && sudo ln -s "$(pwd)/lein" /usr/local/bin/modellurgist
2 minutes, 6 seconds
Ciaran Archer
Worked a charm in about 1 minute! @Jamie – that command worked perfectly for me on a Mac OS X Snow Leopard. Much appreciated!
Ralph M. Deal
Less than 2 minutes. Amazing! I’ve installed lots of versions of LISP but none anywhere near this fast. I also used Jamie Krug’s suggestion of putting a link to lein in /usr/local/bin.