For many Java developers, the REPL is the single most valuable reason to learn Clojure. Think of it as a live connection to your running program where you can ask questions, try fixes, and explore data without rebuilding or restarting.
This chapter shows you how to evaluate forms safely, redefine functions, reload namespaces, and keep your working memory close to the code. You will also learn practical habits—like keeping side effects at the edges—so that interactive development stays reliable instead of becoming “state soup.”
If your Java workflow is already strong (tests, debuggers, profilers), the REPL does not replace it. It complements it by making experimentation and feedback dramatically faster.
In this section
-
Introduction to the REPL
Understand the REPL as a live entry point into your program, not just a faster calculator.
-
Evaluating Expressions at the REPL
Learn what actually happens when the REPL evaluates a form, including result values, side effects, and required libraries.
-
Defining and Testing Functions at the REPL
Use the REPL to shape functions with real inputs, then move the proven code back into source files and tests.
-
REPL-Driven Development
Use the REPL as part of a deliberate workflow for exploring, integrating, and restarting code safely.
-
Handling Errors and Debugging in the REPL
Use the REPL to read exception data, recreate failing contexts, and inspect values directly instead of guessing.
-
Using the REPL in Editors and IDEs
Choose an editor REPL workflow that fits your habits, then learn the common evaluation, reload, and inspection moves that matter everywhere.
-
Integrating the REPL with Build Tools
Understand how the Clojure CLI, Leiningen, and editor-driven REPLs decide classpaths, middleware, and daily workflow.
-
Hot Reloading Code
Reload changed namespaces deliberately, and use tools.namespace only when you understand what it will scan and restart.
-
Best Practices for REPL Usage
Keep REPL sessions focused, reproducible, and useful to future-you instead of turning them into private state soup.
-
REPL vs Java's `main` Method
Treat the REPL and `-main` as complementary entry points: one for exploration, one for external execution.