How to manually debug scripts the interactive REPL way


(last time edited: 2021-06-04)

tags: programming, scripting

Read–eval–print loop

A read–eval–print loop (REPL), also termed an interactive toplevel or language shell, is a simple interactive computer programming environment that takes single user inputs, executes them, and returns the result to the user; a program written in a REPL environment is executed piecewise. The term is usually used to refer to programming interfaces similar to the classic Lisp machine interactive environment. Common examples include command line shells and similar environments for programming languages, and the technique is very characteristic of scripting languages.

We need first to familiarize with the REPL term. Read more about it here.

Programming and scripting languages have many different interactive interpreters and we wanna test our programs using the comfiest and easiest way.

While the REPL is already interactive, we want to load a chunk of code or a program file on it so then we can test functions, variables, lists, etc. This is called interactive session.

I'll show how to do it on a few scripting languages.


$ irb -r ./path/to/script.rb


$ python -i


$ lua -i script.lua


$ node -i -e "$(< script.js)"


$ php -a