There. I’ve said it - I am addicted to the REPL.

Looking back, it has been one of the best learning tool for me - today I know it’s called the REPL

What is the REPL ?

For those of you who didn’t read the wiki link from above, here’s the excerpt :

A Read–Eval–Print Loop (REPL), also known as an interactive toplevel or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user; a program written in a REPL environment is executed piecewise. The term is most 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 is particularly characteristic of scripting languages.[1]

So, why am I talking about this weird acronym REPL ?

The answer is simple - I’ve been using python for some experiments with Apache Spark.

(Please note the emphasis on the word using. What I mean is I have not learnt the python language completely. I am barely using what I need from it.)

While I’ve been playing around with Spark, I’ve used the PySpark interactive shell extensively. The key word there was interactive - you throw in some code, it spits out results. No fancy IDEs or build scripts/commands to see the output.

As I dug deeper into Spark, I started needing more python to code what I wanted to. And here is where the python shell came into the picture.

FalconAir:Development amrithyerramilli$ python
Python 2.7.13 (default, Dec 18 2016, 07:03:39) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> f = open('2017-files-cleaned.txt', 'r')
>>> x = f.read()
>>> len(x)
91217772

The interactive shell is what has got me hooked right now - I simply fire up a terminal, open up the shell and code away.

Why am I addicted ?

For starters, the shell like interface has been the best learning tool for me. I’ve realized it now, while I’ve been learning python that I’ve been a fan of this interactive coding interface for a long time!

JavaScript - Chrome’s dev tools console was my initial JS playground. I later learnt about other tools like JSFiddle, Plunker

Node - Yeah it’s a runtime based JavaScript - so it provides a lovely shell. Go on, type node into a terminal and get going!

C# - Umm, yeah - until recently (I’ll get to that in a bit), I don’t think I’ve used an interactive interface for programming in C#. I’ve been a slave to Visual Studio and making console applications. Of course, I later went cloud and started using .NET Fiddle.

HTML - Quite sure we’ve all learned this through a “live preview”. Maybe on Adobe Dreamweaver? Or probably on the W3Schools TryIt Editor

So - you get my point. Learning a language is pretty damn amazing with instantaneous feedback through these REPL based interfaces.

Python took this a notch higher and gave us the world of notebooks.

And well - like I said earlier, C# has it’s own notebook like interface - Xamarin .NET Workbooks.

I no longer write “console apps” to try out some code or experiment or have a bet. I use the shell.

I no longer write utility apps which make my life a little simpler. I use the shell.

And yes - I’m becoming a fan of this world of this interpreted language

REPL allows you to try out designs and code out quickly. Any change you make to the system is live. Following a tutorial/documentation with code examples is a piece of cake - cmd/ctrl + c and cmd/ctrl + v into the shell! Forget about adding watches - just print it whenever, wherever. Shortening turnaround time and feedback loops as much as possible is incredibly important to a developer’s sanity.

Conclusion

I am addicted to this style of learning. As a programmers, I tend to trial-error a lot of things. I feel like I’ve made good use of the REPL.

  • Check out repl.it for a host of web based fiddles/shells