Review of “ANSI Common Lisp”
Posted on July 14, 2008
Filed Under Programming, Programming Languages |
Why Lisp?
A few months ago, I decided that this summer would be the summer I learn Common Lisp. There are two bloggers who are at fault for this decision: Steve Yegge and Slava Akhmechet . Linked are the pertinent articles, both proposing and explaining the idea of data storage as a Lisp program.
The idea is beautifully simple: Why spend the time to parse and transform your XML into usable code when you can get parsing, for free , in an equivalent S-expression? To me, this is simple, yet profound. it helped me realize why I wanted to learn Lisp: It’s interesting . Lisp is functional, it uses a very different syntax than any other coding I’ve ever used, its macro support causes pseudo-religious experiences, and a lot of very smart people swear by it.
At this point, I’ve spent almost a month going through ANSI Common Lisp by Paul Graham. I’ve read through the book once, and I have played around with a lot of the exercises in the top-level interpreter. I am currently solving all of the exercises, chapter by chapter.

How was the book?
The Good
I would never in good conscience let someone teach themselves their first programming language with this book, but it works very well for the experienced programmer. Mr. Graham explains most of the concepts very clearly, programmer-to-programmer. He gives design rationale, anecdotes, interesting history, helpful diagrams, and good examples.
As opposed to many authors that attempt to build all knowledge from the ground up, Mr. Graham starts by giving the reader enough tools to be dangerous. The first coding chapter, Chapter 2 , gives the readers functions, printing, variables, lists, conditionals, and introduces the idea of recursion for the uninformed.
For me, this was wonderful. Once I figured out what Lisp environment I wanted to use (I ended up using SBCL in Slime), I spent some time experimenting with the Lisp equivalents of the building blocks I knew from other languages. If anything can be learned of Paul Graham from Arc, it is that he likes to experiment. In this vein, he gives the reader plenty of opportunities to play with the syntax of Lisp.
The explanations of the fundamentals (cons, predicates, lambdas, structures, etc) were all very well done. Unfortunately, his meticulous explanations were not a constant through the whole book. For example, the explanation of functional programming techniques like closures was cursory, even though he constantly refers to the importance of functional programming in Lisp. Were better explanations the victim of strict editing? It’s difficult to tell.
These missing or unsatisfying explanations were few and far between, however. For the most part, this book was well-conceived and well-explained.
The Great
Some of my favorite math books are the texts that have tons of examples, and Paul Graham followed this style successfully. The biggest challenge of learning Lisp is thinking in Lisp. I’m used to a C++ style syntax and thought process, so Lisp was hard to work with in the beginning. Thankfully, the example code written for the book was up to the challenge: In fact, it was the best part of the book.
Every idea presented comes with the necessary code to run it. Every chapter has one or two minor sample applications that use the concepts presented in the chapter. Typing these into the top level interpreter and puzzling through their rudimentary logic helped infinitely more than his explanations. This is not to say that the explanations did not belong in the book. However, they were at best a supplement to the sample code.
Mr. Graham also includes a few badass applications, such as ray tracing. The book has examples of real programs that perform interesting work, and the practical grounding gives the book a sensible air.
The Cons
Some of the exercises left for the reader showed quite a bit of carelessness on a few levels.
First, some of them were not even solvable, Chapter 3 standing out in my mind. One of the exercises asks you to find the longest finite walk in a graph, cycles allowed.
You show me your longest finite walk with a cycle, and I’ll show you one better.
Next came the lack of volume of exercises. All of the exercises are short exercises. Very short. Each of the questions either asks you modify a previously-written program in some minor way, or to write a small snippet of code.
The lengthy puzzles were lengthy because I was trying to find a common trick, such as passing a lambda function to a reduce call in order to switch argument order. On one hand, I appreciated these puzzles, but couldn’t help but wonder if they were better suited as examples in the text.
Don’t get me wrong! A lot of the questions are there to ensure that the reader has learned very basic Lisp concepts, and the book wouldn’t be as effective without them. However, I never got the appreciation for medium-scale application design in Lisp. All of the problems were very small and situational, designed to help the newbie understand simple features of Common Lisp.
Do you recommend this book?
Absolutely.
At the end of the day, coding books are just an excuse to get the reader to write code, and ANSI Common Lisp succeeds marvelously. Code is clearly the central focus of this book, and most of the code is well-supported by explanations. Even though there were not enough programming exercises, and there was a notable absence of hard programming assignments, this text works very well as a “First Common Lisp Book”. Going through all of the exercises will give you a nice introduction to Common Lisp, and if you’re like me, an in-depth examination of compiler and interpreter errors of the Common Lisp implementation of your choice.
Do I feel like I am a Lisp programmer? Hardly. However, this book has given me an appetite for learning more about the language.
Next up:
Paradigms of Artificial Intelligence Programming by Dr. Peter Norvig. Given its size, I’m sure the review will be ready by 2012.
Popularity: 35% [?]
Comments
9 Responses to “Review of “ANSI Common Lisp””
Leave a Reply

I can highly recomend the book Practical Common Lisp, by Peter Seibel (http://gigamonkeys.com/book). It was /the/ book that got me into Lisp. I got the hardcopy, but it’s also freely available online.
(Disclaimer: I haven’t read anything by PG yet, mostly because of criticism of his Lisp-style.)
Hi, I really enjoyed your review.
Paul Graham’s other book “On Lisp” does cover closures in great detail and is available as a free pdf from his site.
With regard to the problem of finding “the longest finite walk in a graph, cycles allowed”: I think that what Paul intended is for you consider graphs that contain cycles - the walk should not contain a cycle itself.
Best of luck with Dr Norvig’s tome!
I would recommend “Practical Common Lisp” but after seeing your other posts it looks like you are one of those guys that would probably like SICP and PAIP more.
I’m working at a company that uses Lisp, as an intern, this summer. I wouldn’t recommend ANSI Common Lisp as a book from which to teach programming to oneself, but I definitely find it to be a very good reference book. I find a lot that many of the definitions given in the Hyperspec are not descriptive enough, or maybe sometimes rather cryptic. It definitely explains things well, and I’d recommend it to anyone who does a lot of programming in Lisp.
Nice review. I’ve also decided to learn Lisp this summer, although I ended up going with Practical Common Lisp as a text instead.
I’d like to point out that while Peter Norvig still recommends Paradigms of Artificial Intelligence Programming as a Lisp text, he no longer recommends it as an AI text and instead the more recent book he cowrote, Artificial Intelligence: A Modern Approach [ http://norvig.com/Lisp-retro.html end of the article] It tends to be light on the programming and mostly use pseudo code, but it is an excellent AI text that covers a lot of area. Unless you really, really want it as a Lisp book here, I’d recommend this AI: A Modern Approach.
You might want to read Paul Graham’s “On Lisp”, which is available free at:
http://www.paulgraham.com/onlisp.html
He wrote it before ANSI Common Lisp, and it covers the more advanced topics in Lisp, mostly metaprogramming, but also functional programming.
Guy L. Steele’s “Common Lisp: the language 2nd Ed.” may also be of use to you. The book is found here: http://www.cs.cmu.edu/Groups/AI/html/cltl/cltl2.html
I strongly second the recommendation for Practical Common Lisp. I own it as well as both of PG’s books and I think it’s a significantly better introduction to the language and develops a reasonable-scale application through its course. Seibel of course had the benefit of PG’s books coming first, but I think he really did do a better job with teaching Lisp than previous books. I’d still recommend to anyone learning CL buying ANSI Common Lisp and downloading On Lisp if you can’t find it, but Practical Common Lisp is the place to start.
[...] up, Graham. I taught myself from “ANSI Common Lisp“. At first, I attacked the problems in the book from a C++ perspective, trying to wedge loops [...]