I am currently teaching programming languages to second year students. I spent about 4 weeks introducing Scheme to them and I covered the following topics:
- Expressions
- Functions
- Scope
- Recursion and tail-recursion optimization
- Pairs and lists
- Higher-order function
Each lecture was followed by a lab session where students practiced what they saw in class.
I then gave the students an assignment to do where they had to write moderately complex higher-order functions. Last week, I asked the students to demonstrate to me what they had done. During the demo, I asked them a couple of questions.
What did they think about the assignment
Most students told me that they liked the assignment even if it was moderately tough. This was a surprise to me as I did not expect the students to like assignments. But this might be normal as I devised the assignment to appeal to the social networking generation. Another possibility is that many students managed to do a substantial part of the assignment without having to copy from a friend as Scheme is so beginner-friendly and powerful at the same time.
What did they think about Scheme
Many of them told me they found Scheme (and the DrScheme IDE) easier to understand than C++ which they used in Year I. Some said that higher-order function were very powerful and made their functions very compact yet powerful and easy to understand. A few didn’t use higher-order functions at all and relied on plain old recursion to solve the problems (that’s ok with me).
Interestingly, some students told me that Scheme should have been used in Year I instead of C++.
My opinion
I agree with them and I think there are two important reasons why Scheme is better than C++ for teaching programming:
- Scheme, when used as a functional language, is waaaaaay simpler than C++. The only keywords we used were define, let*, lambda, cond, cons, car, cdr, add1, sub1 and null? With those, students managed to build very powerful functions. Compare this to the complexity of ISO C++.
- Scheme has DrScheme which is, quite simply, the best Integrated Development Environment for students. It has fantastic stepping and tracing facilities (which are pretty much essential when one is learning…) and also provides a very powerful read-eval-loop. I learned programming around 1987 using a BASIC interpreter and I guess I would have become a poorer programmer if I only had a compiler at that time.
Of course, Scheme can be replaced by something like Haskell or even by the disciplined use of Ruby or Python.
The point is to use a simple (subset of a) language with a beginner-oriented IDE featuring a read-eval-loop. This is the exact opposite of using the most complex programming language ever with an IDE designed for professional software developers.
The top five universities in the world can’t all be wrong after all :-)