So you want to learn LISP...
Somewhere you've heard about LISP. Maybe you read some of Paul Graham's essays like i
did, or his book of essays Hackers &
Painters; maybe you read Eric Raymond's advise on How to
become a hacker--whatever lead to your new curiosity, you
now are faced with a question: how do i go about learning LISP.
Unfortunately that question isn't as easily answered as it is for most
other languages. Python, for example, makes this question
trivial. I could point you to the Python documentation, or
possibly one of several books, and upon reading through those you
are more or less a Python programmer. To understand why there's no
single and easy to refer to resources on LISP, we need to
understand more about LISP, actually we need to understand more
about LISPs.
LISP, a family
The name LISP
is derived from Lisp Processing: the programs you write are
lists (in prefix notation, if that means anything to
you). However, that doesn't say much about a lot of things like
what other data types are available, what functions or procedures
are available, etc. In fact, there are a number of different ways
to do these things, and a number of different LISP languages to
match these different ways.
Right now there are three popular LISP languages:
- Common LISP
- An ANSI standardized LISP, which includes an object system,
rich data types, and a huge library of functions.
- Scheme
- A base language that was defined to be as small as
possible. To do anything practical you must find libraries or
build you own on top of the language.
- Emacs LISP
- The language used to extend (as well as implement) the Emacs editor. The language is
not often used for other purposes.
To make an analogy, the differences between the LISPs are somewhat
like the differences between C and C++ and Java and C#: they all
use very similar syntax, yet differ in quite a few ways, and often
have different philosophies.
Common LISP (CL) was the family that Paul Graham used in his
startup. It seems to be a good choice for doing large work in,
since it has such a large standardized base. Scheme is often used
more for research (since it is so easy (small) to implement), but
can also be used for much larger systems, especially if a person
decides to focus on a single set of Scheme libraries.
LISP and multiparadigm
So now your question has gone from "how do i learn LISP?" to
"which LISP should i learn, and how do i learn that one?". Again
i'm not going to answer your question, but will say that Scheme
would be the easiest, but for many projects CL will be the more
useful. Actually, i'd highly suggest learning both!
Python has a philosophy
that "there should be one -- and preferably only one -- obvious
way to do it." This is more or less true of many languages--the
language designer has some paradigm in mind (OOP for example) and
that becomes the way that you solve problems in that
language. Some languages, like Perl, give you a lot more
room to play then others, but this is still more or less the case.
LISP, on the other hand, is inherently a multiparadigm programming
language. You can write object oriented code, or not; you can
write functionally or imperatively; you can use dynamic variables,
or use declarations to have the effect of static typing; you can
even (and often end up doing so) make a new language for the
problem domain you are working in! Because of this, learning LISP
is more then just about learning a new syntax, a new philosophy, an
accompanying library--learning LISP, to do so fully, is really
about learning computing. This may sound daunting, but it's also
exhilarating, and exactly the reason that Paul Graham was able to
use the language to his advantage and to the disadvantage of his
competitors: suddenly you are not forcing your problem into a
philosophy your language wasn't intended for, but rather you can
use whatever philosophy fits your problem. There's also no reason
that you have to learn everything, in fact it is probably quite
impossible to do so; you can become productive with a rather tiny
subset of LISP, and then slowly grow your knowledge as you go
along.
Resource recommendations
To summarize non-answers: there is no single LISP to learn, and
no definitive way to do so. The following are resources i've found
valuable:
Multimedia:
- Structure and Interpretation of Computer Programs
- This is a series of lectures recorded at HP in the 1980s by
two MIT professors. You would think that a set of lectures in
the field of computing given over 20 years ago would be way out
of date, but surprisingly this is not the case! Sussman and
Abelson do an excellent job conveying the excitement and
enlightenment. The accompanying book, also named Structure and Interpretation of Computer Programs, is freely available online. (note: you'll see the book commonly referred to as SICP around the net)
- The Swine before Perl
- Download the slides and
listen along to the mp3. This is really more of a wet your appetite resource.
Books:
The following sites have much more complete list of books:
Books that i've read, or am reading:
- ANSI Common Lisp, Paul Graham
- This was the first book i read about lisp. While its an good
book for very beginners, it only got me so far, and left me with
a lot of unanswered questions. It also makes very poor
reference. A big problem i had at this stage was trying to get
code from the book to work with Lisp interpreters i had. Since
all the interpreters have differences in how they work (like how
they report errors to you) its not an easy problem for authors
to solve. Probably the best solution is to have someone around
to ask questions to when your at the beginning stage.
- On LISP, Paul Graham
- This is a fairly advanced book, too difficult for me last time
i tried reading it (a year ago). A good portion of the book
is aimed at teaching the craft of macros, which is inherently
difficult. Graham (somewhere) states that macros are difficult,
not because they are somehow obfuscated, but for the same reason
that calculus's integrals are difficult: you are doing
fundamentally powerful and thus difficult things: transforming
functions.
- The Little Schemer, Daniel Friedman and Matthias Felleisen
- This seems to be aimed at being a book for people who have
never programmed before. I was into the third chapter of Lisp
in small pieces when i picked up this book, so that also
probably helped to weaken it in my view (underwhelming). A lot of
people rate it highly as helping you to think in Lisp, i think
that watching the Structure and interpretation of computer
programs lecture series does just as good of a job, and is
a lot more exciting.
- Common Lisp the Language 2nd edition, Guy L. Steele Jr
- This book was published prior to the finalization of the ANSI
standardization of Common Lisp, but it's pretty close, and makes
an excellent reference. It's also one of the best ways to learn
some of the CL language features like Conditions. Not
really a tutorial though. (note: this book is commonly referred
to as CLTL)
- Paradigms of Artificial Intelligence Programming, Peter
Norvig
- This is a CL book. While the name is AI, the book is very
heavily CL, and covers a lot of the most popular paradigms of
programming in CL. Unfortunately i've not read a lot of this
book, but what i have read has been really good. Seems like it
assumed some (beginner level) prior knowledge of LISP. Probably
wouldn't' suggest you read this as your first book, but you don't
have to be anyware close to a master before you do pick it
up. (note: this book is commonly referred to as PAIP)
- Structure and Interpretation of Computer Programs
-
This is a Scheme book. See my description under the multimedia
section of this document.
- Lisp in small pieces, Christian Queinnec
- I love this book. Its probably not for the faint at
heart thought, and definitely not for the beginner LISP
programmer. It is "a comprehensive account of the semantics and
the implementation of the whole Lisp family of languages". What
that means, is that all the various aspects of LISP dialects are
taken apart and examined (in a very academic way). For example,
the section on the difference between LISP 1 and LISP 2 (the
number of namespaces) shows how the implementations between
those two differ (which is really surprisingly small like in
the tens of lines of code), as well as examining what are the
various advantages and disadvantages of each. When you get done
with each section, you'll have an incredible understand of that
aspect of LISP (assuming you were able to keep up with the
chapter :)). Great bedtime reading!
- Object-Oriented Programming in Common Lisp, Sonya E. Keene
-
I thought this was a really good tutorial on CLOS. Its
rather short, and very practical. It will very quickly get you
up to speed with the most common use of CLOS. I've not yet done
much with CLOS, so i can't tell you how good of a reference it
makes, i suspect not a great one.
- The Art of Metaobject Protocol
- This is suppose to be the definitive book on CLOS (it
basically implements CLOS). Unfortunately i've read but a few
pages, so i can't say much more.
- Practical Common
Lisp
- While this book isn't finished, quite a few of the chapters
are already in fairly complete stages. Seems to live up to its
name for the few chapters i've read.
- Successful
Lisp
- I'd also class this book as being fairly practical. Should
hopefully get somebody who already programs up and running
fairly quickly. I learned quite a bit from reading chapters of
this book. Being online makes it much easier to search then
physical books.
- Teach Yourself Scheme in Fixnum Days
- Good book, although it's about a specific implementation of
scheme (mzscheme), so some of the knowledge won't even transfer
to other scheme implementations.
Webpages
- Cliki is a wiki for CL which
has a really good list of implementations, libraries, and
books.
- Schemers: a list of
scheme resources.
- Planet Lisp is a
collection of blogs on Lisp (mostly CL). Great way to learn
random topics and see news.
Other
- comp.lang.lisp: usenet newsgroup. Best place to ask questions and/or lurk.
|