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 :-)
Raj says
I like the “And I also tried to make them understand that becoming a competent programmer require practice like all artistic endeavors. “, specially the artistic bit.
What a coincidence, on Sunday I launched a challenge to my niece to learn Scheme in two weeks and I downloaded DrScheme :-). I was drawn to Scheme based on what I read in your blog and of course pointed her to your site to get some idea about how computer science is taught at UOM.
Alex Ciarlillo says
I am a CS student at Ohio University in my senior year and would just like to add my thoughts coming from experiences I’ve had here.
Last year I had my first encounter with functional languages in a university class. We used MzScheme and wrote our own language interpreters. As a programmer I’m very familiar with abstraction but in Scheme it took on a whole new meaning. We used Scheme for the entire course and at times I found it frustrating, (cadr, cddr, caadr, and a screaming sack of parentheses still haunt me) but it really opened me up to approaching problems in a new way and with a whole new bag of tricks. And for some reason it also prompted me to learn Vim :)
As for Ruby… this is the language I use on a daily basis for office work and I really feel that it can be used as an excellent tool for a wide variety of tasks from simple text/excel processing to light user apps. However, what I find really nice about the language and why I am happy to hear you are considering introducing it to students is that just like scheme it offers a really nice playground to experiment in (much love for irb). It also looks a lot like pseudo-code that one sees in classes on algorithms and theory and I don’t see why it cannot be used more often to highlight conceptual material like this so that students can be less concerned with the intricacies and syntax of languages like C/C++/Java and can more clearly see the problem and its solution in a concise and readable way. Also if you do use ruby there are many really cool lightweight libraries capable of doing really neat things from retrieving AudioScrobbler data (my latest interest) to browsing iTunes shares via DAAP and tagging MP3s. I’m not sure that any of those type of things will fit it in at all with the course material, but maybe you could come up with some projects or assignments that are not only useful but also interesting or useful to students.
Okay that was a bit long winded… and liberating in an odd way :)
Kailash says
Worked on building an introductory programming language for my undergrad project some years back.
I thought that I’d ask a true hacker, Richard Stallman about the features he might foresee in the “ideal” introductory programming language. Interestingly he replied that there was little need to create anything… use Scheme. hehe!
Damian Conway, the man behind OO Perl and who also happens to work on introductory programming at Monash University, however thought that Stallman was wrong. Scheme is semantically challenging for beginners. You cannot expect students to make sense of a series of nested brackets. His paper about seven deadly sins of introductoy programming language design was somewhat the basis behind my dissertation.
Maybe now we can have some insight which is which. Would the non “hackers” like scheme?
avinash says
To Raj:
How old is your niece?
To Alex and Kailash:
Thanks for your comment Alex. I also have some problems with the parentheses but using a good editor like the one in DrScheme (which features automatic indenting and parentheses-matching) makes life easier.
I don’t see the parentheses after some time. Indentation is much for important for comprehension. And I’ve discovered the Ctrl-I shortcut in DrScheme which automatically indents your program and make errors so much obvious…
Thanks Alex for your idea of giving meaningful and interesting projects to the students. I’ll explore some of the most interesting Ruby libraries.
As for the paper by Damian Conway, it’s a nice read (I read it some months ago). But it’s easy to criticize but so much more difficult to come up with something perfect. Scheme is not perfect. But it’s good enough for introducing functional programming and this is sufficient for me.
As for “would the non-Hackers like Scheme?”, I never equated Scheme with hackers. For me, Scheme is the programming language invented to introduce programming. I learnt Scheme in my first year of university in France. I know this is also done at MIT and Berkeley. There must be a reason.
Incidentally Ruby, Haskell, Python etc. are also nice. In fact, any language with a REPL is good enough to be used to introduce programming like I wrote above.
Kailash, did you read Richard Gabriel’s essay?
Raj says
Avinash
My niece is waiting for her HSC results and is considering a degree in IT hence my challenge to her to make sure she’ll be up to the standard and not be one of those who finish a degree and want to become a manager or project leader after 6 months programming.
avinash says
Excellent!
Dijkstra always told people that he was a programmer even though he was one of the gods of Computer Science. I guess most people are not like Dijkstra: they feel Programmer is not a good title and that Manager or Project Leader sound much better :-)
kailash says
So how did scheme turn up to be? Do they like it?
avinash says
Hi Kailash, check this blog entry.
Insah says
Hi Mr Meetoo,
Thanks for inspiring n motivating us in programming. Im a 2nd year student in Electronics and Computer Science at UOM and i study programming languages with u. I love scheme a lot. I have a different and interesting view and trend of thought of programming, and it is becoming a way of life instead of just cramming syntax in our heads only to pass exams. Im very happy to have you as a lecturer who teaches us the essence of things and how blissful it is. Every friday from 9am to 11am, i have a great time with the way you teach us computer science which is not just science but a ingenious invention of man that when he uses it correctly, he can do almost anything. It would be great if u keep on motivating and helping us to achieve greatness. Have a nice evening.
Regards,
Insah Bhurtah
ECS 2
UOM
avinash says
Thanks for this very nice comment.
It’s great to know that students appreciate the way I teach. My objective is to make you become autonomous and be able to learn any programming language or paradigm by yourself and have fun in the process…