UP | HOME

REPL

REPL

REPL stands for a ~R~ead, ~E~val, ~P~rint, ~L~oop.

This is an ancient tool which goes back to early LISPs. It is still one of the most important innovations in the history of programming.

The main point is that with REPL one can:

  • do literal experiments to see what is going to happen (presumably by evaluating pure functions).
  • Trying this and that is at the core of any learning activity. This is a form of practice.
  • evaluate exactly the same expressions (presumably in the same order) as a program at runtime would do.

Usage of a REPL as crucial part of a programming experience is emphasized by Paul Graham (the “On LISP” book), Rich Hickey (the author of Clojure) and Simon Peyton Jones (you know who he is).

Inside Emacs when you press M-x you are getting sort of a REPL.

Haskell has ghci, Ocaml has utop, every decent language since LISP or ML has its own REPL because of the same input - same output property which pure functions in mostly-functional languages have. Even Python… Nevermind.

The REPL heuristic

There is an important heuristic related to a REPL. If your functions are too difficult to use in a REPL, either due to verbosity, too many parameters or just felling awkward (you have to switch mental contexts) then you have designed a crappy use-side (a whole set of related function signatures).

Author: <schiptsov@gmail.com>

Email: lngnmn2@yahoo.com

Created: 2023-08-08 Tue 18:41

Emacs 29.1.50 (Org mode 9.7-pre)