This guide is for developers who have at least a basic understanding of Clojure, and want to become more proficient at using the Clojure REPL.
A Clojure REPL (standing for Read-Eval-Print Loop) is a programming environment which enables the programmer to interact with a running Clojure program and modify it, by evaluating one code expression at a time.
The Clojure REPL gives the programmer an interactive development experience. When developing new functionality, it enables her to build programs first by performing small tasks manually, as if she were the computer, then gradually make them more and more automated, until the desired functionality is fully programmed. When debugging, the REPL makes the execution of her programs feel tangible: it enables the programmer to rapidly reproduce the problem, observe its symptoms closely, then improvise experiments to rapidly narrow down the cause of the bug and iterate towards a fix.
Many Clojure programmers consider the REPL, and the tight feedback loop it provides, to be the most compelling reason to use Clojure. This does not mean that the language features of Clojure, such as immutable data structures, are not valuable: the Clojure REPL gets most of its leverage because of these features, in particular because Clojure was designed with interactive development in mind.
In Clojure, a programmer will typically use the REPL for a wide spectrum of programming tasks, when in another language she would turn to other sorts of tools. Such tasks include:
launching local development environments,
running automated test suites,
one-off database queries and interventions,
debugging,
orchestrating remote machines,
getting familiar with libraries and APIs,
…and many forms of exploration.
Fundamentally, the reason programmers use the REPL for all these tasks is always the same: because they want a mix of automation and improvisation that can be provided neither by fully manual tools (such as dashboard, consoles, etc.) nor by fully automated ones (such as scripts), while keeping their workflow focused in one full-featured programming environment.
This guide will start by getting you started with a Clojure REPL, then gradually move to more and more advanced ways of using Clojure REPLs.
Depending on your needs, you may not need to read the entirety of this guide:
If you are just starting to learn Clojure, the first 2 chapters Launching a basic Clojure REPL and Basic Usage are enough to get you started with a productive learning environment.
As soon as you start developing non-trivial programs (such as a hobby web app), you will need the ideas presented in at least the next 2 chapters: Data visualization at the REPL and Navigating namespaces.
For working on Clojure projects at a professional level, Enhancing your REPL workflow and Guidelines for REPL-Aided Development are must-reads.
First, we’ll learn how to launch a basic Clojure REPL.