Reading

423,905 hits

A Scheme bookshelf

January 31, 2007 — jao

It all began while i was using MDK‘s development as an excuse to learn everything i could about programming and programming tools: makefiles, autoconf, automake, localization, texinfo docs, lexers, parsers… and, eventually, extensibility. I kept hearing about an exotic thing by the name of GNU’s Ubiquitous Intelligent Language for Extensions, and, finally, rose to the bait. But my first attempts at writing Scheme felt awkward. Not because of the parens (i liked Scheme syntax from day zero), but basically because i was writing C code using Scheme. Clearly, i needed to read a bit about this new thing and, to that end, i got a copy of The Little Schemer… to no avail: i didn’t get what elephants, food and Socrates had to do with programming; i still felt awkward. (It was not the book’s fault, mind you, but mine. More about this in a bit.)

Then i found the book. Abelson and Sussman’s Structure and Interpretation of Computer Programs changed my life as a programmer. I’m sure you’ve read lots of praise for this book. Totally deserved! SICP is not really about Scheme, but about thinking about programming. Reading it will make you a better programmer in any language. It will expand your mind. It will cure your diseases. It’s really that good. Besides, SICP is freely available in HTML, PDF and texinfo formats, so you really have no excuse. For extra fun, get the accompanying video lectures, by Abelson and Sussman themselves. These lectures are charming: these guys have a passion for what they do, and they transmit it from the very beginning, when Abelson jokingly explains why computer science is neither a science nor about computers.

The most cited alternative to SICP is How to Design Programs by Felleisen, Findler, Flatt and Krishnamurthi. Its authors have even published a rationale, The Structure and Interpretation of the Computer Science Curriculum, on why they think SICP is not well suited to teaching programming and how their book tries to fix the problems they’ve observed. I won’t try to argue against such eminent schemers, but, frankly, my feeling is that HtDP is a far, far cry from SICP. HtDP almost made me yawn, and there’s no magic to be seen. If for whatever reason SICP is not your cup of tea, i would recommend Max Hailperin‘s Concrete Abstractions as a far better (as in more fun than HtDP) alternative.

With SICP under my belt, i was ready for The Little Schemer and The Seasoned Schemer(by Daniel P. Friedman and Matthias Felleisen), which i read in a row. You’d be hard pressed to find any programming book similar to the Schemers books. As in my case, the initial reaction may well be of rejection: on a superficial reading they look too queer, even childish, and by any means the kind of book a serious programmer should read, except maybe for fun. But that’s precisely the point: you won’t learn unless it is for fun! If you enter the game proposed by Daniel and Matthias, accepting to participate in their Socratic scheme, you’ll learn a lot with their books. I found easier to put me in the right mood after SICP because it also is imbued of a kind of magic, and also because i was much better equipped to capture the subtleties lurking in every page of the Schemers books. Besides having a great time, one ends up with a sound grasp of higher order functions, recursion (including the Y combinator) and continuations. In fact, it was reading The Seasoned Schemer that something clicked and i really understood continuations.

After all these readings i felt i was starting to have a good grasp of the conceptual underpinnings of Scheme and Lisp, and that it was due time to strengthen the technical details. Or in other words, i wanted to come to grips with the nitty gritty details of Scheme syntax and semantics, including macros (which i knew from some tutorials and readings on Common Lisp). To that end, Dybvig‘s The Scheme Programming Language was the perfect book. Comprehensible, exacting and with an elegant prose, and to the point. But, despite its succinctness, Dybvig does an excellent job in conveying the details of the language and its usage. The book also includes extended usage examples for a good measure. Thus, TSPL works nicely as both a tutorial and a handy reference.

If you already have a good basis on functional programming you can use TSPL as your first Scheme book and skip the previous ones (but you will be skipping lots of fun and, maybe, insight too). And if you happen to read French, an interesting alternative for a speedier learning path is Jacques Chazarain’a Programmer avec Scheme. In the first part of the book, Practical programming with Scheme, Scheme is thoroughly presented, using it in many examples taken from the standard data structures and algorithms curriculum. Taking this practical basis as a starting point, Chazarain proceeds to a comprehensive (almost 400 pages long) discussion of the formal basis of the theory of programming languages: automata, lexers and parsers, propositional calculus, rewriting systems, logic programming, lambda calculus and more. As you can see, the scope of this book is amazing, and it’s well worth learning a little French!

The nice thing about learning a programming language in such a good company is that one learns much more than a single programming language. These books helped me obtain a conceptual basis for thinking about programming and programming languages in abstract terms, applicable to any programming problem. As Sussman colorfully demonstrates in one of the SICP lectures, one feels like beholding the heart of the spirit that lives in the machine. An that spirit, of course, is an interpreter. So i delved into the theory and practice of implementing interpreters guided by another classic: Essentials of Programming Languages by Daniel P. Friedman, Mitchell Wand, and Christopher T. Haynes. This marvelous book delves deep into the art of writing interpreters using Scheme as the implementation language. By way of running example, an interpreter for an ML-like language is developed all along, showing the magic of, among other things, register machines or continuation-passing style. To get a flavor of what this book has to offer, i wholeheartedly recommend reading Friedman’s The Role of the Study of Programming Languages in the Education of a Programmer, an insightful talk on how a theoretical background is useful (and even needed) to any programmer in any language, which Friedman illustrates with practical cases taken from his book.

One of the rites of passage of any self-deserving schemer is writing a metacircular scheme interpreter, that is, a scheme implemented in itself. Having a look at the innards of your language implementation sheds a whole new light on your daily usage of the language. Sussman goes as far as wearing his magician’s hat when he explains the metacircular interpreter in the SICP lectures, and rightly so. But i’ve always felt a bit frustrated by the fact that the implementations one finds in books like SICP, EOPL or, to cite another classical example, PAIP are actually for toy interpreters not covering all the details of real Schemes. And often the left out precisely the most interesting bits! Fortunately, there’s a book that will tell you everything you ever wanted to know about implementing Lisp interpreters and compilers: Lisp in Small Pieces by Christian Queinnec. This is easily the best book about Lisp i have ever read. LiSP shows, without omitting any details, how the family of Lisp languages is implemented (in interpreted and compiled forms). You’ll learn from the inside the difference between Lisp-1 and Lisp-2, how dynamical and lexical scope work, how blocks and continuations are related, how on earth one implements… everything you ever wanted to know about Lisp implementations, and then more. On top of that, Queinnec writing style is engaging and the book is pervaded by a fine sense of humour that made me laugh out loud several times. If you’re serious about Lisp, you must read this book.

Let me close my list of recommendations with the last addition to my Scheme bookshelf, namely, the third schemer installment: The Reasoned Schemer (by Daniel P. Friedman, William E. Byrd, Oleg Kiselyov). Paraphrasing Alan Perlis, the key reason for learning new languages and paradigms is the fact that they, hopefully, change the way you think about programming. Functional languages do a pretty good job at that, but they’re not the only game in town. Declarative programming is definitely another mind blowing experience, which you can enjoy reading The Reasoned Schemer. The book presents, in that peculiar style of its predecessors that i like so much, the basis of logic programming using a Scheme implementation that, in many ways, surpasses standard declarative languages like Prolog. The best of two awesome worlds, and an excellent way to ensure that you keep learning and expanding your programming horizons.

Like this:

Related

24 Responses to “A Scheme bookshelf”

I’m slowly making my way through _How To Design Programs_, and I don’t find it as boring as you say. But then you’re a seasoned programmer, while I’m a novice.

While the Wizard Book might be an excellent book, it seems less suitable for a complete beginner as I am (actually, I’m also being teached Ada95 at University, but I hope that will not damage my brain that much ;-) ).
I didn’t know about _Concrete Abstractions: An Introduction to Computer Science Using Scheme_. Just downloaded it, I’ll take a look at it.

Once I’m finished with HTDP, I intend to jump on the Haskell bandwagon (using Hudak’s _The Haskell School of Expression_ ?) What do you think?

And afterwards… Object-Oriented Software Construction? Accelerated C++? Any advice will be welcome.

Very good informative post. I think the best general book every programmer should read is Eric Raymond’s The Art of Unix Programming. By explaining the architectural and practical choices made by the original Unix programmers every programmer today can learn from their experiences.

I am in the midst of reading both SICP and OnLisp (by Paul Graham). I took the introductory CS class from Brian Harvey at UC Berkeley. All of it was very mind bending, although at the time I didn’t realize how much. Only now am I beginning to realize why Lisp is Lisp.

On a slightly different topic: how can their be people having this type of Scheme learning experience and simultaneously there be claims that “Lisp is dead.” I read more posts on Lisp/Scheme/Haskell from Reddit than on almost any other language. The community seems to be more vibrant than previously thought.

Jing Qi, i didn’t mention Harvey’s Simply Scheme because i haven’t read it, so i haven’t got an opinion on it. That said, i’ve seen some of the videos of his Berkeley course, and i always enjoy his posts on comp.lang.scheme. So, my guess is that it’s a pretty good book too :)

“Programmer Avec Scheme” is a veritable well of knowledge.
That you can cram so much advanced material in a single book is a testament to the power of Scheme.

There are some other books I would like to mention:

– Scheme and the Art of Programming, by George Springer and Daniel P. Firedman (McGraw Hill).
Intended as a stepping-stone to SICP, it is a very nice tutorial book.
The last chapters go into OOP, mutable states (simulation), extending the language, and control (two chapters on comtinuations).

– Simply Scheme, 2nd ed., by Mathew Right and Brian Harvey (MIT Press).
A “prequel” to SICP. Another interesting beginer book. The last part of the book is interesting, because it discusses the implementation of a spreadsheet program (BTW, there was once an open source office, called Siag Office, that was implemented in Scheme – Siag meaning “Scheme in a grid.”)

It’s good that you mentioned the paper on HTDP. In my own experience, HTDP works better than SICP. SICP being deeper and more “philosophical.” Of course, SICP is a computer science classic. Oh, you that have not read SICP – you ignorant fools!

One book I have not read is Programming and Meta-Programming in Scheme, by Jon Pearce.

To the dude reluctant about learning a little French, I have this to say: I guess most non-US American programmers are used to having to “learn a little English” to read what they need to read. In particular, I’m also used to reading a little German too, or a little Spanish, or a little whatever it is. In fact, things could be worse. I could be Chinese. Or Indian. Russian, or speak Arabic as my native language. Then I would have a hard time. Since I was born in a country with a Western language, my task is a lot easier.
And then American programmers complain they are loosing their jobs to foreigners…You could try not being so lazy.

Knowing “a little” English will not help you read at a technical level, which is what these books are. It takes at least 500-900 hours of constant study to achieve a “near native” fluency in a language (and that goes for everyone. You are not special, you would not whiz through it faster)

So, idiot, he is not talking about learning a “little french” – the kind you would get from a dozen hours of study, the ability to use a few common phrases like “Where is the bathroom?”. To read at a 16th grade level, you’d need many solid months.

You don’t need “near native” fluency to read technical books in another language that is sufficiently related to your native tongue. Most european languages are sufficiently related.

My native languages are German and Spanish. While expressing my own thoughts or reading prose and poetry in English can be hard, I read CS books like SICP or math papers without feeling any language barrier at all. Of course this is challenging stuff, but certainly not linguistically.

So I guess, you could read ‘Programmer avec Scheme’ with a very narrow knowledge of the French language, that would never ever allow you to read Proust or even to talk to people on the street.

If you already know the basics, and you want to learn Scheme, then definitely begin with “How to Design Programs” (HtDP). It is slow paced, very detailed and instructional and it uses the DrScheme environment which is very extended and multi-platform.

SICP is simply the best. It really is deeply philosophical and not at all easy. I have read it twice-ish, and don’t even feel like i’ve gotten an eighth of what it has to offer. Lil’ Schemer is also wonderful for getting used to thinking Schematically.
I think it’ll be interesting to take a look at Programmer avec Scheme- I’ve been wanting to learn some French…

[…] SICP, or “The Wizard Book”) is considered one of the great computer science books. Some people claim it will make you a better programmer. It was the entry-level computer science subject at MIT […]

The link that used to be available is no longer valid. It now leads to an online scheme course. I sent email to the course administrators and they have told me that they no longer publish this book since they have now put the entire course on line. So now the call goes out to anyone that has an electronic copy of this book to help. Mine was lost in a basement flood a few weeks ago here in Toronto and I desperate to get it back.