The Little Schemer and The Seasoned Schemer

I’ve been working through these two programming books, on and off, since some time last year. I’ve just finished the second of the two, so it’s time for a book review. I’m considering them as a single book because they are both fairly small, and one continues right after the other; even the chapter numberings continue across the two books, and functions from the first book appear in the second one. I took a few months gap between the two books, but it’s probably better to continue straight on so the concepts from the first book are fresh in your mind.

The Little Schemer book coverThe books use the programming language Scheme to teach certain interesting programming concepts. They’re not designed to actually teach you the language, although I’m sure the material covered will be useful when I do go on to learn Scheme from a more practical point of view. The first book, The Little Schemer, is all about learning to think recursively, while The Seasoned Schemer is more about functions, and also covers state and continuations. Continuations in particular were a new concept for me before I started the book.

The books are in the form of a conversation between the authors and the reader, with questions in the left column of each page, and answers on the right. I found I got most out of the book by covering up the right column until I’d thought about my answers, otherwise it’s too easy to just glance over and read the answer. Mostly the questions you’re asked, especially those that ask you to write a function in Scheme, are pitched at exactly the right level of difficulty.

Occasionally this question and answer format was frustrating though, where the authors deliberately ask you a question that you don’t know how to answer yet. There are also places where some more explanation would have been helpful. The final chapter has you building an interpreter for Scheme in Scheme, but the book doesn’t tell you in advance that this is what you’re doing (or why). I think this would have helped me to keep the big picture in mind while working through this chapter, making the individual functions easier to understand as I went along.

The style of the book is humorous and playful throughout, with pictures of cartoon elephants at the start of each chapter, and example lists being composed mainly of food. While the childishness of this could annoy some people, I really liked it. It looks like a children’s book, but don’t be fooled. The contents will definitely stretch your brain in new directions. After the book’s toughest section, which covers the applicative-order Y combinator, the authors playfully ask “Does your hat still fit?”

I came at these books as an experienced programmer, although not in Scheme, so I’m not sure how suitable they would be for a complete beginner to programming. In theory the gradual building up of understanding through progressively harder questions would be ideal for beginners. But there are some difficulty spikes that I think complete beginners would get stuck on, and the complexity of the larger examples might be daunting for those not used to reasoning about larger programs.The Seasoned Schemer book cover

The most enjoyable questions are those that get you programming. Typically you’ll be introduced to a new function by seeing its effect on various lists, then you’ll be asked to write it. You could probably go through the book using a pen and paper to write your functions, checking them against the answers in the book. But there are going to be occasions where your answer differs slightly from the book’s answer, so it’s useful to be able to run the code and test it yourself. For the harder questions I found this essential. Also it’s much more satisfying (and a better learning experience) to find and fix your own mistakes before you see the correct answer.

For running the code, I used Racket. DrRacket is a nice simple GUI for writing and running code. It supports multiple varieties of Scheme; I found the standard “#lang racket” setting to be mostly fine, although there were a few minor changes I needed to make, such as using let/cc instead of letcc.

There were a few places in the text where the authors didn’t make it easy for me to actually run the code though. For example, they have you define your own version of the + function, using a slightly different + symbol. While DrRacket does support the use of unusual symbols to name functions, it’s kind of annoying to have to use (and could confuse beginners) when it would have been easy enough for them to use a name like ‘plus’ instead.

Overall though, this is a great pair for books for gaining a deeper understanding of programming and as an introduction to Scheme. Most of the problems, especially those in the first book, are beautifully satisfying to solve. It’s a brilliant, fun way to learn this style of programming, and you can almost feel yourself getting smarter as you work through the books.