Introduction

Labrepl was developed by Relevance as the coursework for Pragmatic Studio Clojure training. As an attendee of the training course I highly recommend it! Its coursework is known as labrepl and Relevance graciously made freely it available.

I am writing this to give some additional context to people who want to benefit from labrepl outside of an instructor led course. I strongly encourage people to take instructor-led Clojure training if at all possible. Also, this document is an individual effort which has no relationship to labrepl or Relevance.

Labrepl was designed with self-study in mind. Its labs:

Technical introduction

Labrepl is many things:

Some of these features are provided for convenience only. For example, Leiningen is not a requirement. The Maven POM and .bat files in the script/ directory make labrepl work easily on Windows. Conversely, avoiding Maven and going the Leiningen route works too. Circumspec is optional if you decide to write test files with clojure.test and run using lein test.

Getting started

Please see the official readme for detailed installation instructions. While the labrepl web application can be started by most IDEs, here is an example of starting it from the commandline:

$ script/repl
Clojure 1.2.0-master-SNAPSHOT
2010-04-22 08:16:27.210::INFO:  Logging to STDERR via org.mortbay.log.StdErrLog
solutions.mini_browser.proxy$javax.servlet.http.HttpServlet$0
2010-04-22 08:16:27.232::INFO:  jetty-6.1.21
2010-04-22 08:16:27.333::INFO:  Started SocketConnector@0.0.0.0:9000
labrepl.proxy$javax.servlet.http.HttpServlet$0
2010-04-22 08:16:27.335::INFO:  jetty-6.1.21
2010-04-22 08:16:27.342::INFO:  Started SocketConnector@0.0.0.0:8080
Welcome to the labrepl. Browse to localhost:8080 to get started!
user=> "hello, world"
"hello, world"

Several things are going on here. The web application has been started on localhost:8080. This is running as a background process. Also note that the user=> prompt has appeared, which means the REPL is ready to be used.

Running tests is done with script/test. This runs Circumspec tests, which is a version of RSpec for Clojure. Stu Halloway has released a screencast for Circumspec which I highly recommend. Here is an example of using Circumspec:

$ script/test
solutions.rock-paper-scissors-test
  mean beats stubborn (life advice perhaps?)
    should replay last winning value
56 success, 0 failure, 0 error, 0 pending [4711 msec]

Navigating labrepl

The labrepl web application lists all of the labs in a suggested order. This order worked fine for an instructor guided course. I have tried to list a few different paths through the labs. People just wanting to read up on the basics of Clojure have a path. People wanting to write some basic code have a slightly longer path. A few links have been collected for labs covering specific areas of interest. Beyond that, I recommend completing all of the labs.

Labrepl must be running for these links to work!

A short, useful introduction

  1. Intro
  2. It's all data

Write some code!

Prerequisites:

  1. Intro
  2. It's all data
  3. Names and places

Try any of these...

Lab summary

Here is the list of labs each with a very short summary. Again, labrepl must be running for these links to work.

Lab Micro-summary
Intro What's a REPL?
Names and places Namespaces and loading libraries
It's all data Data types, collections
Looping Iterating and recursion
Project Euler FizzBuzz in Clojure
Mini browser Write a small webapp!
Unified update model References change, values don't
Zero sum Make transactions, not locks
Cellular automata Conway's game of life in Swing
defstrict Macros have DRY superpowers
Rock paper scissors Clojure-oriented Objects

Conclusion

Revelance designed Labrepl for both instructor-led and independent study. I have tried to provide a little bit of extra context to help new Clojurians use labrepl outside of training. By all means try to take some instructor guided training on Clojure if at all possible. Also, this webpage is a personal contribution to the Clojure community and has no official or unofficial relationship to Relevance or labrepl.

Many thanks to Relevance for making labrepl freely available to the Clojure community!