Blog Post, Programming, Tutorials

Creating your First Clojure Program in Linux

Those who really want to start learning a language will find it easier to start learning the language by setting up a REPL as fast as possible. This makes it easy to experiment with some simple expressions. This post will covers the installation of Clojure and an editor on Ubuntu Linux to set up a REPL.

Since Clojure runs on the Java Virtual Machine, one will need to install Java on your system. This, Here, is an easy way to do exactly that.

Now that Java is installed, one can install leiningen, a helpful tool for managing Clojure projects, especially when starting with Clojure.

To Install Leiningen:

Use Ubuntu’s package manager:

apt-get install leiningen

Or use wget:
wget puts files in your current working directory, which is home by default.

wget https://github.com/technomancy/leiningen
chmod +x lein # make executable. Make sure you are in the correct directory when you use this command
lein self-install

Installing a text editor:

Many people like using slime emacs for Clojure development, but for people who haven’t used emacs before I suggest using Nightcode. It is easier not to have to learn Clojure and a complex text-based editor like emacs at the same time. For this reason, Nightcode is a good alternative.

To install Nightcode download the .deb file and double click on it to open a window with the option to install it on your system.

Creating a New Leiningen Project:

In the terminal type:

lein new app first_proj

Lastly, open the project in Nightcode. A “Hello World!” console application is already generated for you.

Leave a Reply

Your email address will not be published. Required fields are marked *