To better understand REPL-driven development, I recently watched Sean Corfield’s presentation “REPL Driven Development, Clojure’s Superpower” and reviewed the referenced “dot-clojure” setup repository. While I understood the explained concept and approach to REPL-driven development, I’d appreciate help in confirming/clarifying aspects of the setup and in turn Clojure’s REPLs.
In the setup, the configured alias “:dev/repl” loads the “dev.clj” file. This file, among other tasks, starts a socket REPL server and rebel readline, which I believe starts Clojure’s “main” REPL - a separate and distinct REPL.
- Is the above described understanding correct?
- Furthermore, what is the difference - if any - between a socket REPL server and Clojure’s main REPL?
- Assuming the preceding is accurate, what benefit would there be to running two separate REPLs?
As I understand things, the REPL is a part of the app being developed (or even deployed). It is the part of the application responsible for reading Clojure code (text), convert it to data, compile it, evaluate it and giving you back (printing) the results. The evaluation step will possibly cause side effects like printing to stdout/stderr/etcetera, mutating the application, writing to disk, contacting servers, or whatever.
The socket REPL is an interface to this REPL. It’s from where the text is Read. It’s role should be compared with that of nREPL, which is a server you can run in your application that will feed the Read part of the REPL process and be the interface between your editor and your running application’s REPL.
Consider the REPL as a process that runs Clojure code The process reads each expression in turn, evaluating each expression (compiling and returning a result). This process runs regardless of if developing Clojure or running Clojure in production.
During development, a connection to that REPL is established. The user interface for this connection can be a Clojure aware editor, a terminal prompt, etc.
A connected editor can then evaluate code, using the source code written in files or via a REPL prompt. Code expressions are sent to the REPL process using the connection and results received over that connection.
The connection to the REPL is typically done via nREPL (network REPL), although in Sean’s video Socket REPL is used.
Most editors are used with an nREPL connection, although Chlorine and Clover editors are typically used with a Socket REPL connection (as seen in Sean’s video)
It is also possible to configure a REPL connection to a deployed Clojure application, although if a production application, then great care and security measures should be taken
My overview of REPL driven development REPL driven development · Practicalli Clojure
To clarify a bit: They also support nREPL.
I am trying to start the same thing as shown in the video. But I am stick to Practically deps.edn and Visual Studio Code. And the most close command to start Reveal, rebel and nrepl I found so far is