Setup

This workshop requires Leiningen to create, manage and run projects. Any text editor is fine, preferably with Clojure syntax support. You also need Java runtime environment, preferably version 1.8 or greater.

Java

Check you have a Java runtime on your system path by typing the following in a terminal window:

java -version

If Java is not found, please install it from Oracle or OpenJDK. Java may also be available via your operating systems package manger, for example on Ubuntu / Debian systems this would be installed via sudo apt-get install openjdk-8-jre

Leiningen

Leiningen is the most commonly used build automation tool used to manage Clojure projects. Install by saving the Leiningen install script and running it inside a terminal window

Save the file to somewhere on your operating system path, eg ~/bin

chmod a+x ~/bin/lein
lein

The first time you run this script it downloads a Java archive file (JAR) of the latest version of Leiningen. When you run the script again, you have a working Leiningen build tool.

Development tools with Clojure support

A tool that understands Clojure will help you write code faster and more accurately. Here are a few common development tools used for Clojure

  • LightTable - has an Instarepl that evaluates your code as you type, great for Clojure beginners
  • Emacs with either Emacs Live, Spacemacs or CIDER - highly extensible support for Clojure, auto-completion, snippets, REPL & refactoring.
  • Nightcode - good for beginers, nice Clojure on Android support
  • SublimeText - simple editor with basic Clojure awareness, used with lein repl on the command line

Clojure

There is no specific install for Clojure. Clojure comes as a library, a JAR file, managed by the build tool Leiningen just like any other dependency.

When you create a project with Leiningen, the configuration is created in a file called project.clj. Inside this project.clj is a :dependencies entry where the version of clojure is specified along with any other dependencies. Here is an example of a project.clj configuration with just Clojure as a dependency

(defproject project-name "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]])

The Clojure library is very small (~3.6Mb) and Leiningen caches it and all other libraries locally in the same folder structure that Maven uses, eg Clojure version 1.8.0 would be cached in ~/.m2/repository/org/clojure/clojure/1.8.0/

Heroku Postgres

The web application will also use a database to persist state. For this project we are using the Postgres relational database, an open source and well maintained project with all the features of a modern database you would expect.

To save on installation, we will use Heroku Posgres, a database on demand service that has a free tier for development.

To start with, create a free account on Heroku. The step to create a database will be covered later on in the workshop.

Alternatively, you can install Posgres database locally on your laptop, however assistance with this is not provided.

results matching ""

    No results matching ""