[ Content | View menu ]

Your First Programming Language Needs A REPL

Mark Mzyk | January 22, 2008

REPL: noun

Read-Eval-Print-Loop: an interactive top level or shell; a simple, interactive computer programming environment.

That definition was shamelessly adapted from the wikpedia article.

Floating around the web lately, there has been a lot of debate about whether Java should or should not be the first programming language taught to someone. It was started by this article: Computer Science Education: Where are the Software Engineers of Tomorrow? The responses have been numerous and varied. I haven’t been bookmarking them, so I’ll leave it to you and the power of Google to find them if you want to read them. Needless to say, there isn’t a consensus on the issue. It wouldn’t be fun to follow if there was.

Recently, in my own education, I’ve been working on learning Erlang. Erlang is not my first language. In fact, it’s not even my second. I first learned Java. Then I learned some assembly, then C. From there I moved on to C++. I then left school and learned PHP for my work. I’ve even dabbled in some Flex. Yet Erlang has something none of the previous languages I’ve worked with have (or if they do, I didn’t learn with it): a REPL.

A REPL, as defined above, is nothing but an environment where you can input some code and the REPL then spits the output right back at you. No need to compile, no need to wait. This, to me, is simply amazing.

Perhaps I sound like a small child in awe. It’s because I am. Programming Erlang, even only the very simple operations, is incredibly fun. I find myself extending what I’ve been reading because it’s easy for me to just type it in the REPL and see what is output. I play, I experiment. I’m a kid again.

I didn’t have this experience with Java. There was so much underlying boilerplate I had to understand. Then I had to compile and wait. This made it more of a chore instead of something like an experiment. It contributed to my frustration at learning the language. At the time, I thought it had to be this way. You had to slog through the tedium to get to the joy at the end. Only by putting in the work did you get the reward. Wow, was I wrong.

You can argue all day if Java is a good first language or not, if GUI tools are necessary or not, etc. In my opinion though, whatever first language someone is taught, it should have a REPL of some kind. It isn’t about making it easy. It isn’t about avoiding the underlying math or hidden concepts. It’s about fostering an environment that encourage exploration and experimentation.

If you want to be a biologist you can start by studying the plants that grow outside your door. Interested instead in chemistry? Cook something, observe how it changes. Psychology? Play mind games with your brother, see how he reacts. Why can’t computer science be this accessible? Why haven’t we made it this accessible? Actually, we have, but for some reason we haven’t done a good job disseminating the knowledge of just how accessible it can be. It starts with the REPL.

I don’t care what language you prefer. If you’re going to teach someone comptuer science, start with a languaget that has a REPL of some kind. I don’t even really care what kind of REPL it is, so long as it promotes exploration, experimentation, and enjoyment. It can exist for Java so a nine year old can understand it. It can involve a turtle. Too simplistic? I’ve already mentioned Erlang. There’s also Lisp. Even Python.

Sometimes it takes being a kid again to understand how things should be. In learning, don’t discount the power of playfulness and wonder that comes from instant feedback.


  1. Comment by Brian Adkins:

    Hey Mark, I found a link to this page from your comment on bluej.org, then I discovered that you’re in the Raleigh area working for Lulu, so I thought I’d say hi.

    REPLs are certainly useful – I primarily program in Ruby and occasionally try out snippets of code in irb.

    Erlang is on my list to learn, but it’s behind a few others :)


    As far as a first language, I think it’s hard to beat Logo, but there are quite a few that would be good. I personally prefer a text based language over one that heavily uses an IDE such as Squeak/Smalltalk.


    January 28, 2008 @ 09:43
  2. Comment by Mark:

    Thanks for the comment Brian. It is always nice to hear from other locals.

    January 28, 2008 @ 23:31
  3. Pingback from REPL i PHP – czyli Telnetem do rakiety :) | TeMPOraL's devBlog:

    […] Przydatność narzędzia jakim jest REPL jest nieoceniona, wypadałoby zacytować pracownika NASA JPL dotyczący awarii na pokładzie sterowanego zdalnie pojazdu kosmicznego: Debugging a program running on a $100M piece of hardware that is 100 million miles away is an interesting experience. Having a read-eval-print loop running on the spacecraft proved invaluable in finding and fixing the problem. […]

    September 15, 2009 @ 11:46