A REPL is the foundation of the Clojure coding experience. The REPL provides a runtime environment where you can instantly get the results of evaluating your code. You can write code in a REPL too, although typically code is written editor and sent to a REPL to be evaluated. When you start coding, the first step is to run the REPL and keep it running until you are finished.
A REPL is the same environment used for running your Clojure applications too.
Lets look at the newest and fastest approach to running a Clojure REPL, the Clojure CLI Tools and rebel-readline.
The Clojure CLI tools included in Clojure 1.9 provides a REPL that starts instantly, so its a great way to introduce developers to Clojure.
Follow the Clojure CLI Tools Getting Started Guide to install on Linux or Mac (Windows is not supported at time of publication). Once installed, use the
clj command in a terminal to start your REPL.
Library dependencies are defined in a file called
deps.edn which uses the Extensible Data Notation (EDN), the data notation that Clojure is designed on top of.
- Clojure EDN Walkthrough - Compound Theory
- A Case for Clojure - James Reeves - London Clojurians meetup at Skillsmatter
- Rich Hicky - extensible data notation - HackerNews
Rebel-readline enhances the REPL experience by providing multi-line editing with auto-indenting, language completions, syntax highlighting and function argument hints as you code.
With the CLI tools installed, run the following in a terminal:
That should start a Clojure REPL that takes its input from the Rebel readline editor.
cljcommand wraps the process with another readline program (rlwrap), so does not work with rebel-readline.
Alternatively, specify an alias in your
And then run with a simpler command:
When you run
clojure for the first time with rebel-readline it will take a few seconds as it will download the library dependencies.
What is a readline
allows multi-line editing and general navigation around forms using the keyboard arrow keys
This work is licensed under a Creative Commons Attribution 4.0 ShareAlike License, including custom images & stylesheets. Permissions beyond the scope of this license may be available at @jr0cket