DEV Community

Cover image for Moving faster with REPL

Moving faster with REPL

Jonathan Cass on February 25, 2018

Introduction to REPL Developers like to "move fast and break things." Well, we like to move fast anyway. A "REPL" is a tool I've found t...
Collapse
 
eljayadobe profile image
Eljay-Adobe

I always thought of Python having more of an interactive shell, rather than a REPL.

The REPL in Lisp also has the ability to inspect, debug, edit, on live code. The REPL is like having a built-in IDE, at the caliber of PyCharm.

Python distinguishes code from data, whereas Lisp does not. Python is not homoiconic, which Lisp's REPL leverages heavily.

Python print(repr(eval(raw_input("> ")))) compared to Lisp (loop (print (eval (read)))) has several other important differences. Python's eval works on only expressions. Python's eval combines parsing and evaluation, which leads to perennial Python problems of "safe eval" and "string representation of a dictionary" (leading to ast.literal_eval). Lisp's REPL is core to the engine, so a developer can extend Lisp at the most fundamental level (and has access via the REPL to the core engine; the developer can change the syntax of Lisp itself, such as by using W-expressions or L-expressions instead of only S-expression), whereas Python's interactive shell does not provide that kind of extensibility.

That being said, I'm a Python fanboy, and I don't much care to program in Lisp. Your mileage may vary.

Collapse
 
joncassdev profile image
Jonathan Cass

Thanks for your thoughts!

Yeah, to be honest I actually haven't used Lisp, and it's definitely not a perfect analogy. I think that for simple use cases, the various flavors of shell, REPL, etc are somewhat interchangeable, but it is an important distinction as things get more complex.