Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Noob question. I am not quite able to tell the difference between a REPL and an interactive shell just by reading the definitions on Wikipedia.

Wiki notes that REPL is a particular kind of interactive language shell. Is it a proper subset though? The Wiki definition seems to restrict the terminology REPL to Lisp-like languages, whereas the stated properties don't really contain any distinguishing features.

In particular, would it be correct to call IPython a REPL?

share|improve this question

REPL: This is a procedure that just loops, accepts one command at a time, executing it, and printing the result.

The three steps at each iteration of the loop are:

  1. Calling read to read the characters that make up a textual expression from the keyboard input buffer, and construct a data structure to represent it,
  2. Calling eval to evaluate the expression--intuitively, eval "figures out what the expression means," and "does what it says to do," returning the value of the expression--and
  3. Calling write to print a textual representation of the resulting from eval, so that the user can see it.

You can write your own read-eval-print loop for your own programs, so that users can type in expressions, and you can interpret them any way you want. You can start up your read-eval-print loop (by typing in (rep-loop)), and it will take over from the normal Scheme read-eval-print loop, interpreting expressions your way.

Here's a very simple read-eval-print loop:

  (define (rep-loop)
  (display "repl>")      ; print a prompt
  (write (eval (read)))  ; read expr., pass to eval, write result
  (rep-loop))            ; loop (tail-recursive call) to do it again

Notice that the expression (write (eval (read))) does things in the proper read-eval-print order, because the argument to each procedure call is computed before the actual call.

Interactive Shell : An interactive shell reads commands from user input on a terminal. Among other things, such a shell reads startup files on activation, displays a prompt, and enables job control by default. The user can interact with the shell.That's how the interactive shell name came into being . Let us consider this bash script :

     echo -n "Enter the value of variable 'var1': "
     read var1
     echo "var1 = $var1"

    echo -n "Enter the values of variables 'var2' and 'var3' "
    echo =n "(separated by a space or tab): "
    read var2 var3
    echo "var2 = $var2      var3 = $var3"
    #  If you input only one value,
    #+ the other variable(s) will remain unset (null).

    exit 0

Now the script above interacts with the user, it asks the user to enter inputs based on which it does its calculations. That's why it behaves like an interactive shell.

Similary, the python interpreter which most people use to learn python is an interactive one as it communicates with its user.

share|improve this answer
Excellent explanation – Moogs Sep 29 '15 at 18:44
@Moogs : Thank You ! – The Dark Knight Oct 1 '15 at 13:22
@The Dark Knight : So based on the above theory, can we say that developer toolbar(in chrome) or firebug extension (in firefox) is kinda REPL? – R J Feb 1 at 9:41

Technically, it's correct to say that a shell is an instance of a REPL. However, it isn't a matter of program definition as it is one of common usage scenarios.

Bash, for example, is written in C, but it could well have been written in Python. At that point, if you talk about program features and abilities, would it be correct to say that Bash is a shell while Python isn't?

You could also say that Shells are about running commands while REPLs are about running instructions and function calls. But can't you run commands in REPLs (Python's os.system, os.popen, etc), and can't you run (or define) functions in Bash, using many of its built-ins?

As aforesaid, it's a matter of usage. If you juggle files and ready-made programs, you're using it as a shell. If you're testing libraries or language semantics, it's a REPL.

Hope that helps.

share|improve this answer

This StackOverflow question discusses that very question (among other things).

I am personally on the fence as regards interactive Python. But, if you want to call it a REPL, I don't think anyone will be angry with you (there are slightly too many things that work in source code files, but not in the interactive shell for me to be entirely happy with calling it a REPL).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.