Clojure REPL-Driven Development — The Inner Loop That Defines Clojure | Episode 21
0views
C
CelesteAI
Description
The REPL isn't where you test Clojure code. It's where you *write* it. In this episode we grow `parse-person` one form at a time — splitting, trimming, destructuring, assembling — all from a live session that never restarts. The rich-comment block is your scratchpad, and the REPL holds state across everything you try.
We also force a crash — `NumberFormatException` on `"thirty"` — and watch the REPL shrug it off. Prompt comes right back. That resilience is what makes the inner loop feel different from every other language's REPL.
Student code: https://github.com/GoCelesteAI/clojure-for-beginners/tree/main/episode21
Every keystroke is shown on screen with generous pauses so you can follow along at your own pace.
What You'll Learn:
- `(comment …)` rich-comment blocks — the REPL scratchpad pattern
- `(require 'ns)` and `(in-ns 'ns)` — load once, then live inside the namespace
- Growing a function incrementally: split → trim → destructure → assemble
- Why REPL state survives errors — stack trace prints, prompt returns
- `(require 'app.core :reload)` — pick up file edits without restarting
- When the REPL beats "edit → save → re-run" every time
Timestamps:
0:00 - Intro
0:15 - Preview: the inner loop
0:52 - The finished file and its comment block
1:08 - Start the REPL
1:16 - require + in-ns — live inside app.core
1:32 - Step 1 — split on commas
1:43 - Step 2 — trim each piece
1:55 - Step 3 — destructure into names
2:08 - Step 4 — the whole function together
2:18 - A different person
2:27 - Force a crash — "thirty" as a word
2:38 - The REPL survives
2:51 - Control-D
2:57 - Recap
3:34 - What's next: Episode 22
Key Takeaways:
1. The REPL is the workspace, not the afterthought — keep one session alive.
2. `(comment …)` blocks are ignored at load time but eval fine from the REPL — use them as scratchpads committed to source control.
3. Errors print a stack trace; they don't end the session. Redefine and retry.
4. `(require 'app.core :reload)` re-loads a namespace after you've edited its file.
5. Growing a function one form at a time, with live feedback, is faster than any edit-save-rerun cycle.
Phase 4 continues. Next up: testing with `clojure.test` — turning the functions you just grew into a green test suite.
Taught by CelesteAI. Like and subscribe for more Clojure tutorials!