Falling in Love with Scheme

Since I have some three months before I start my computer science course at college, I decided that I’d get a head start and learn some real computer science (not just programming) before I get started. Though I’ve dabbled with a number of programming languages (and have a number of “beginning” books thanks to Apress publishers) they really aren’t good for computer science per se. I’ve decided to go with a long-standing computer science classic: Structure and Implementation of Computer Programs.

The book has been the textbook for MIT’s introductory computer science course for over two decades and has a wide reputation. One of the reasons that it has been regarded as a classic is that it doesn’t use any “industry standard” programming language at all. Rather it uses Scheme, a dialect of LISP, a functional programming language and one of the oldest to still be in active use. Scheme is extremely well-suited to be a “learner’s language” for serious computer scientists and it’s hard to actively use Scheme without being deeply impressed by it. Even though I have only been using Scheme for a few days, I’m already in love with it and though it isn’t quite my favorite programming language, I really enjoy using it, much more than most of the other languages I’ve used before. Here’s why:

Scheme has very little syntax

One of the things that makes Scheme stand out from most other common programming languages is that it is a functional programming language with very little actual syntax. All the code that you write is part of a function and your program works as a series of interactions between these functions. Not only are there no classes, or objects, there are not even the more common syntactic forms such as loops (while, for, do-while etc.), these are implemented via function recursion. In fact, besides the function definitions, the only major syntax students have to deal with are conditional statements in the form of an if-else idiom and a general conditional syntax with multiple conditions and corresponding actions, such as:


(test1 expr1 ...)
(test2 expr2 ...)
(else exprn))

Though there are an abundance of data types, students do not really have to bother about these when they get started. All this means that any intelligent student can grasp the fundamentals of the language within a few hours and concentrate on actually learning computer science concepts and their implementations.

Scheme has a great IDE

… in the form of Dr Scheme. Though not really necessary to use Scheme, this IDE makes it very easy to get down and dirty with Scheme. Not only does it offer several implementations of the language (so it’s useful for a wide variety of CS courses), it let’s you immediately run and test code that you’re written. The standard window features both a text area for you to write your function definitions and an interactive interpreter right below it where you can directly use your functions.Along with that there are also simple debugging tools which let you step through your program to find out what’s wrong. Here’s a screenshot to show you what I mean.

DrScheme's multiple panes

Scheme really isn’t a language at all

Many programming languages are created because some people somewhere want a better way to get something done. For Scheme, however the story is a bit different. Scheme has it’s basis in mathematics and in fundamental theories regarding programming language implementation. As a result Scheme is not bound by arbitrary standards or needs to get it to work like other people expect it to. In Scheme, all the code is written in the form of S-expressions, a type of mathematical expression. Add to this it’s complete lack of syntactic sugar and the fact that it’s implementation is based on the theories of lambda calculus, and you end up with something that feels more like a slightly peculiar way to organize your logical thoughts rather another programming language. I personally have come to view Scheme as a sort of “executable pseudocode”. I find that once I’ve come up with an appropriate algorithm to solve a problem, it takes almost no effort to put it into code. This is far from the experience I’ve had with languages like C++ and Java where coming up with running code can be as cumbersome as getting a working algorithm.

Scheme fundamentally changes the way you think

Ask anybody who has worked with Scheme or any other LISP derivative for a considerable length of time, and you’ll probably hear the same thing. Scheme encourages you to put aside the implementation details of a program and concentrate on finding the optimal solution. It’s use of S-expression syntax and functional nature helps you learn to properly segregate the different aspects of a problem instead of letting you cobble everything together. Use Scheme for long enough and you’ll find your Scheme-oriented thinking spill over into other aspects of your life (like wanting to use brackets all the time (and put brackets inside brackets (which is probably something you’ve never done before))). If you haven’t used Scheme yourself, you may not quite have believed everything that you’ve read now, which is actually more evidence for the fact that Scheme changes your thought patterns. If you have a few days worth of time on your hands, go get Dr Scheme and some good Scheme documentation and dig in.

One thought on “Falling in Love with Scheme

  1. Yes,
    Scheme is pretty great. I’m just now getting into it (again) and I find the inclusion of an IDE, a web server and a really cross platform GUI to be a great combination for the price (free).

    Dr Scheme is a pretty decent IDE, especially if you compare it to what is available in python or ruby.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s