In his beautiful essay, The Art of Lisp & Writing, Richard Gabriel makes a strong case for the use of programming mediums instead of programming languages when either introducing programming to students or starting a new project.
He says:
“The difference between Lisp and Java, as Paul Graham has pointed out, is that Lisp is for working with computational ideas and expression, whereas Java is for expressing completed programs. As James [Gosling] says, Java requires you to pin down decisions early on. And once pinned down, the system which is the set of type declarations, the compiler, and the runtime system make it as hard as it can for you to change those assumptions, on the assumption that all such changes are mistakes you’re inadvertently making.
There are, of course, many situations when making change more difficult is the best thing to do: Once a program is perfected, for example, or when it is put into light-maintenance mode. But when we are exploring what to create given a trigger or other impetus—when we are in flow—we need to change things frequently, even while we want the system to be robust in the face of such changes. In fact, most design problems we face in creating software can be resolved only through experimentation with a partially running system. Engineering is and always has been fundamentally such an enterprise, no matter how much we would like it to be more like science than like art.”
[Highlights mine]
I too believe that learning and experimenting require a Language like Lisp, Scheme, Smalltalk, Python and Ruby which offer a read-eval-print-loop (i.e. an interactive shell). Naturally, you’ll always need the big-iron compilers but only when the program is perfected…
As Frederick Brooks writes in The Mythical Man-Month, plan to throw one away, you will anyhow…. In most engineering fields, prototypes are routinely built using more malleable materials than the ones that are going to be used in production (for e.g. airplane prototypes made of wood). It’s only in our field, Programming, that people build prototypes using production-quality (but extremely rigid and constraining) languages like C++ and Java and spend so much time and money in this process that they are forced to ship the prototypes to customers with obvious consequences!
Using a malleable programming language
This semester, I am going to teach Programming Languages to second year university students. Those students have been exposed to C++ in the first year and Java at the beginning of the second year. Both programming languages are good for expressing perfected programs but are bad for experimenting.
(By coincidence, there were two interesting discussions on Slashdot (One Two.) following an article by some professors criticizing Java. Joel Spolsky thinks that it is perilous to use Java at school. I won’t even mention C++ as I personally think it’s the worst (by far) language to be used for teaching programming!
Together with Pascal Grosset who will be handling one of the lab sessions, I have been thinking a lot about what paradigms (and, hence, what programming languages) to use for my lecture. I think that I’ll only have time to introduce three paradigms and, hence, at most three programming languages (or mediums).
This is what we have come up with:
- Functional programming with Scheme
- Logic programming with Prolog (or, maybe, Kanren)
- Scripting with Ruby
The first lecture
I did my first Programming Languages lecture last Friday and I enjoyed it a lot. I arrived in the lecture theatre at around 9:00 and I quickly installed OpenOffice.org on the Windows laptop there as I had prepared my presentation using OO Impress.
During the installation, I asked the 180 students how many of them found programming easy and only a few raised their hands (remember – those are second year students). I was a little surprised because I thought there were more. Anyway, I told them about my little theory that they should make a lot of effort now to acquire knowledge to be effective when they work so that they can return home early and enjoy life instead of having to stay overtime everyday :-)
I also told them that we were going to focus a lot on the functional, logic and scripting paradigms. And I also tried to make them understand that becoming a competent programmer require practice like all artistic endeavors. My first real lecture on Scheme will only begin next Friday as tomorrow is a public holiday.
Why Scheme?
I have been a fan of the Scheme programming language since I was introduced to it during my first year as a university student in France. Since then I’ve found out that Scheme is used at top universities like MIT and Berkeley to teach programming. Why is that so? Because Scheme is easy to learn yet, easy to use yet powerful!
I have decided to use the fantastic DrScheme IDE. It is multi-platform (Linux, Mac OS X and Windows) and is a joy to use. It’s, naturally, open source software. I am currently in the process of installing DrScheme in all the Computer Science labs.
I am still wondering what textbook I’ll use… I bought “How to Design Programs” by Matthias Felleisen, Robert Bruce Findler, Matthew Flatt, Shriram Krishnamurthi a year ago and it is an excellent book written by some of the makers of DrScheme. I am a little bit hesitant to use it as it uses slightly customized versions of Scheme instead of the standardized Scheme. Anyway, I’m still making my mind.
I have also ordered the Schemer triumvirate through Amazon and I expect to receive them in one or two weeks.
“The Little Schemer” is a little book (how surprising!) that covers functions (closures) and recursion. Many of you may feel that recursion is simple but Scheme guarantees that tail-recursive functions are executed without using increasing stack space hence the book goes into a lot of detail.
The second book, “The Seasoned Schemer”, talks about mutable state (i.e. variables) and about the special control flow constructs based on the continuations found in Scheme. Continuations allow for coroutines, concurrency, etc. and are important to understand if one really wants to be a Schemer (a Scheme programmer).
The final book is “The Reasoned Schemer” which is a book on reasoning (aha!). It introduces Kanren, a small library to transform Scheme into a better-than-Prolog programming language for logic and inference.
Why not Lisp?
I’ve also ordered “Practical Common Lisp” by Peter Siebel from Amazon. I have decided not to use Lisp because the de-facto IDE, Emacs + Slime, while extremely powerful, is too intimidating for young students. Another reason is that Common Lisp is a beast and is tough to learn…
Conclusion
Learning by experimenting is the best way to learn. Learning programming using Scheme is fun and rewarding as the language is so malleable. A University is not only a place where people go to get a degree. Rather it’s a place where intelligent people (students + academics) meet to share knowledge. Someone wrote on Slashdot:
“When Plato and Aristotle founded their schools, they didn’t put up a big sign that said “When you’re done, you get more money.” That wasn’t the promise. The promise was that by teaching you about the world, you would become a better person. That is to say, the founding concept of the University was that education lead to human excellence.”
My students will become better persons by experimenting with Scheme :-)