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:
- 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++.
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 :-)
StÃ©phane Lee says
OK, you are telling me that C++ was their first programming language? I fear for your students. Ada or Pascal would be my choice for the first language. C and then C++/Java would be the next languages that the students should learn.
As I always say, one should learn his algorithm first, then pointers and oop.
Yes, their very first exposure to programming was
cout << "Hello world" << endl;
puts "Hello world"
An update: I don’t want to give the impression that the choice of the programming language is the only important decision to make. There is also the choice of the topics to be covered. In my opinion, students are shown the syntax and semantics of the language but not really how these can be used to solve real problems. This is very apparent during the ACM Local Programming Contest we organize every year…
Personally, I think that a mix like Harvard’s is close to perfect: introduce programming to students using C (to understand how a computer works) and Ruby (to learn about problem solving) in parallel.
Having been a beginner once, and far from being currently an expert, I believe:
– Logo is the perfect language for people having only basic computer skills (it’s almost natural).
– Visual Basic : lots of clicking here, easy and fun – but vb can be misleading (people failing to understand the true notions of programming)
– Php makes a perfect starter language, the advantage being that its rules are not very strict (especially as far as variables are concerned), you can start doing lots of things thanks to its library of functions (which makes programming more interesting), added to (my)SQL it can give you notions of databases and given its C-inspired syntax, you can easily move to other languages like C or other C-Syntax-inspired languages. Php was my first ‘serious’ programming language after vb. The problem with php is that html knowledge is highly desirable such that it can become a pre-requisite.
– Python : it is an all-rounder programming language, and being interpreted it can be learnt using the interactive shell, which helps grasp the basics. Added to Tk bindings it can provide strong notions of gui creation (unlike vb’s point and click or php’s html). A great guide (http://www.framasoft.net/article1971.html) helped me get started easily and quickly which is kind of cool.
The problem with Scheme (based on my first glances thereof) is its language style which is unlike other ‘popular’ (C-Styled) programming languages, and hence is confusing for me. I will try to take a better look at that later though.
Thanks for this great comment. I am starting to think that Ruby (or Python) would make a better programming language for beginners than Scheme not because they are better but they look familiar.
Decreasing the pain of adoption is what matters after all…
“The top five universities in the world canâ€™t all be wrong after all :-)”
You’ve still not changed.. when the top 5 universities think they are doing something right… it doesn’t mean THEY ARE RIGHT!
“In my opinion, students are shown the syntax and semantics of the language but not really how these can be used to solve real problems. This is very apparent during the ACM Local Programming Contest we organize every yearâ€¦”
:p hmm .. i believe i am supposed to think i can’t solve real problem because of a local programming contest :D?
*[i or anyone who didn’t win :p]
“I am starting to think that Ruby (or Python) would make a better programming language for beginners than Scheme”
one thing that we both agree on :D
Everything is relative in life: there is no absolute right or wrong.
What is probably true is that when the top 5 universities in the world agree not to teach C++ to beginners and opt for either a functional language or a modern dynamic scripting language then, personally, I am happy to believe that what they are doing is RIGHT.
Since 2006 when we had the first local contest, I noticed two things: (i) few students participate and (ii) among those who participate, few managed to answer more than one question.
This has only one explanation: our students have issues solving problems and writing programs quickly. The important word here is quickly. Given time, most of them (including you :-) ) would solve all problems given…
As for Ruby > Scheme, it’s because Ruby looks more familiar. It has nothing to do with the respective qualities of the two languages.
Given time, most of them (including you :-) ) would solve all problems givenâ€¦
aahh you are wrong about me
:D given time.. i wouldn’t be able to solve it in time there.
ever since i found out why :p [i.e why i will never succeed in that], i automatically got in a good mood and gain arrogance :D
i am 1337 :)
don’t try to figure it out :p
personally, I am happy to believe that what they are doing is RIGHT.
I would hate to be ruled by the *top universities* rather than my own sense perverted sense of reasoning