What Is a REPL? [Read-Eval-Print Loop Explained]

January 8, 2021 · 1 min read
man standing on hill during full moon, painting a circle with light and long camera exposure
Photo by Austin Neill on Unsplash

Every programmer has used one.

Read-eval-print loops (or REPLs) are a centerpiece of modern software development.

What exactly is a REPL, how does it work, and where can I use one?

Let's find out.

You can imagine a REPL as a program that reads your inputs, evaluates them, and prints you the results of whatever you put in. In detail:

  • The program reads your input, usually whatever you type into it
  • It then evaluates your input, which means the program parses it as if it were program code in a specific programming language
  • Finally the results of the evaluation are printed back for you to read. The REPL usually saves the inputs and results of the previous commands as variables so the user can reuse them.

This rings a bell, doesn't it?

REPLs are everywhere:

  • Your shell, e.g. BASH or PowerShell
  • Data exploration and statistical analysis tools like IPython or Jupyter
  • Other REPLs like the ones for Node.js (node) or Ruby (irb)
  • Browser dev tools

With REPLs you can do explorational programming or analysis. They often have autocomplete, making your dev-life easier.

REPLs are especially useful when you want to find a way to do something for the first time without saving and running a file dozens of times.