This article is part of the Learn to Program series for people interested in a self-guided journey into the world of programming. If you’re looking for some help learning to program you might be more interested in our forthcoming application.
Learning to program incrementally
Abstraction is a technique that allows a programmer to make code more general and generic in order to solve a set of problems that share a recurring pattern but aren’t exactly the same.
Object-oriented programming languages like Objective-C and Java don’t make good first languages due to the extra layers of abstraction. Of course, these same abstractions are what make programming in these languages more productive for the experienced software developer, but they add unnecessary difficulties when you approach them as your first programming language. You can’t isolate the basics of programming and ignore the abstractions, they slap you in the face and force you to deal with them.
When you strip away the abstractions, learning to program works best as an incremental process, just like learning the sciences and the arts. Vincent van Gogh spent a great deal of time perfecting his drawing and shading skills before even considering the use of color. The same should go for programming, you need to start with the fundamentals and build your way up. Only then can you understand and appreciate programming languages with advanced abstractions.
Given that the languages all the cool kids are using don’t lend themselves well as a first language, what should a new student learn instead? If you’re familiar with past computer science curriculum my suggestion won’t come as a surprise: Scheme.
A small, rich, and consistent language
You don’t have to look very far in the history of many universities to find a time when Scheme was the teaching language of choice, but that has mostly gone the way of the dodo, being supplanted by more “modern” languages such as Java. This is a real shame considering my points above and that Scheme and other dialects of Lisp are still a relatively popular language in the real world of programming (Clojure being another one of them.)
What is it that makes Scheme such a good teaching language? Scheme is a high-level language like Ruby and Java. This means that beginners don’t have to take a boring detour to learn about computer hardware, registers, pointers, etc. Unlike other popular high-level languages Scheme is relatively minimalistic, that is it doesn’t have all the extra layers of abstraction that can get in the way of learning the basics.
For example, take a look at this snippet of code written in Scheme and see if you can figure out what it does:
+ 2 3)(
Obviously this adds 2 and 3 together.
I know what you’re thinking, you can do this in any programming language and it would look more natural. And you’d be right of course, in nearly every other language the code would be
2 + 3. However, once you understand how the above Scheme works you’ve learned quite a bit about the language and the basics of programming in general.
You can’t say that about most other languages because the various special cases that are part of the syntax (functions vs. operators, infix vs. prefix, statements vs. expressions, etc.). When learning to program using Scheme you don’t have to worry about all that, effectively postponing more advanced syntax until you’re ready.
Making programming fundamentals approachable
Getting back to the Scheme example code from above, it looks weird at first glance. This is because Scheme doesn’t have any special syntax for arithmetic. No rules with a bunch of exceptions. When you reach that moment where you understand that this example code is an invocation of a function named
+ and that it expects a list of numbers as its arguments, you can apply that knowledge to call any other function. That’s it. Adding numbers, launching missiles, and setting variables all use the same syntax.
And guess what, defining your own function is nearly as simple as the example code because the same rules apply, it’s a simple extension of the same syntax. This is another reason why Scheme is so great as a teaching language, the rules are easy to understand and completely consistent throughout. Best of all, these rules can be taught incrementally.
So what are these programming basics and fundamentals that I keep talking about? I’m going to save that for the next article but in the meantime I’ll point you towards some popular Scheme resources.
Chicken Scheme might have a funny name but it’s a complete Scheme system under active development. It’s small, fast, and fun to use.
Racket is a popular programming language in the Scheme family geared towards learning but powerful enough to write commercial-grade software.
Over the course of the next few months I’ll dig deeper into topics covering how to become a programmer using Scheme. If you’re interested in following the series I recommend that you subscribe to the RSS feed or keep an eye on the Learn to Program section of this site.