

Ask YC: Learning Lisp - dmpayton

I've been wanting to learn C for quite a while now, and I went to my local Borders this evening with the intent of finally picking up a copy of K&#38;R. When I arrived, I found myself thwarted -- there was not a copy on the shelf nor in the back.<p>So instead I grabbed pg's ANSI Common Lisp (I actually debated between that and Practical Common Lisp, but large pages of text with few line breaks make my brain hurt).<p>So what's the best way to work through this book? Is there anything I should keep in mind as I delve into functional programming for the first time? I'm not necessarily looking for specific tips on this book, just some pointers on learning lisp in general.
======
gruseom
_So what's the best way to work through this book?_

Get a Lisp and fire up the REPL. Type in the expressions as you read and play
with variations.

I also found it helpful to do the exercises.

 _Is there anything I should keep in mind as I delve into functional
programming for the first time?_

As you probably know, Lisp isn't a pure functional language. It's its own
strange and diverse world. But if you're interested in exploring functional
programming in Lisp (a great idea), one important thing is to be aware of when
your code has side-effects and get good at eliminating or containing them.

Edit: I'd also recommend staying away from CLOS for a while. Not everyone
would agree with that. But my experience has been that focusing on built-in
data structures and higher-order functions is the best way to learn to program
in the functional style. If you're working through ACL, that's the approach
you'll be taking anyway.

------
michael_dorfman
My standard recommendation: begin with the SICP videos, which you can find at
[http://groups.csail.mit.edu/mac/classes/6.001/abelson-
sussma...](http://groups.csail.mit.edu/mac/classes/6.001/abelson-sussman-
lectures/)

I can't think of a more effective way to invest 20 hours.

~~~
fp
Absolutely!

But although SICP teaches you a great deal about Lisp techniques, it doesn't
teach Common Lisp. Abelson and Sussman use Scheme. If you are aware of the
differences, it should be no problem, though.

This has been written 10k times here: The video lectures are great, the book
is great (It's also free on the internet)! If you don't depend on Common Lisp,
this is probably the best Lisp (and programming in genereal) introduction out
there. As a follow-up, Paul Graham's "On Lisp" is a great choice.

~~~
cstejerean
If you can find a copy of On Lisp (I know it's available online but I just
can't read books online).

~~~
fp
Yes, the price on Amazon is just insane. I printed the pdf, which worked quite
well.

------
whalliburton
Build something cool. Rinse. Repeat.

Doing exercises and plowing through books is great but solving your own
problems, to me, is key.

Most books won't even touch the surface of the real things you'll deal with,
like how to interface to C or Java for example, or even mention the most
important part of developing : _other people's code_.

My advise FWIW:

First set up sbcl/emacs/slime. This is really not debatable.

Then in no particular order - think holographic distribution:

a. Hang out on #lisp

b. Read comp.lang.lisp

c. Collect and _read_ and use the free (as in liberty) libraries:
<http://cliki.net> <http://www.cl-user.net>

d. Build software for yourself and your friends

~~~
Hexstream
I wouldn't recommend hanging out on #lisp for a beginner. In my case it set me
in a passive mode and I'd ask a flurry of questions that a little research in
the HyperSpec and other appropriate reference documents would have answered.

~~~
dmpayton
See, I'm the opposite. I can be quite timid in IRC (though this generally
applies to anyone I don't really know), and I always wait until I'm completely
stuck to ask a question. Then I feel like a complete tool when someone points
me to a link I should have found on my own.

So, I don't think I need to worry about entering passive mode. :)

------
silentbicycle
I know you already mentioned and dismissed Practical Common Lisp (free online
at <http://gigamonkeys.com/book/>), but it may be worth a second look once you
get a further through ANSI Common Lisp - they're pretty complementary, IMHO.

You may also find the Little Schemer series helpful (though they explicitly
cover Scheme, almost everything applies to Lisp) for understanding several
aspects of the functional programming mindset. They're also fast reads.
Dabbling in languages like OCaml, Haskell, and Erlang will also round out your
understanding of functional programming.

While I think SICP is fantastic, it strikes me as more of a "spend years
absorbing the deeper ideas in this" book than an "introduction to the tools
and idioms of the language" book. Definitely consider it once you're
comfortable with Lisp, just probably not first thing.

------
zachbeane
Check out
[http://www.cs.northwestern.edu/academics/courses/325/reading...](http://www.cs.northwestern.edu/academics/courses/325/readings/graham/graham-
notes.html) for notes on where Graham's lisp style is notably weird. It also
helps to keep in mind that ANSI Common Lisp is not really about ANSI Common
Lisp, but an ideal Lisp that doesn't exist. To actually learn Common Lisp
(which I can heartily recommend), try Paradigms of AI Programming (despite the
title, it's not especially an AI book) or Practical Common Lisp. CLOS is also
well-covered by Sonya Keene's CLOS book.

------
calpaterson
First and foremost it's critically important to be aware of the mistakes in
the book. Notable are the following:

You should really use DEFVAR to introduce variables, not SETF as graham does.
SETF sets to _places_, and when you use it on undefined variables, the outcome
is undefined, but normally a lexical binding is created. I don't know exactly
why the book does this.

CLOS is better covered by Sonya Keene's book and Art of the MOP.

Honestly, ANSI CL isn't quite as nice as PCL, but my opinion is that they're
both too brief an entry to Lisp, especially for people new to functional
programming and Lisp. "A Gentle Introduction to Symbolic Computation" would
probably be a better start point for CL, as would those Little Schemer books
would be for Scheme.

~~~
jrockway
_Honestly, ANSI CL isn't quite as nice as PCL, but my opinion is that they're
both too brief an entry to Lisp, especially for people new to functional
programming and Lisp. "A Gentle Introduction to Symbolic Computation" would
probably be a better start point for CL, as would those Little Schemer books
would be for Scheme._

I disagree. PCL could have been condensed down to a few presentation slides.
It takes a long time to not say much.

~~~
gruseom
_PCL could have been condensed down to a few presentation slides_

Well, that's a little unfair. It couldn't be condensed to a few slides for
people who don't know Lisp. Which is its target audience, after all.

I do agree that PCL isn't as concise as ACL. But we'd know that from the limit
theorem on Paul Graham's writing anyway :)

------
dmpayton
Wow, thanks for the advice everyone.

Little Schemer is on my to-read list for sure, but I saw ANSI CL and bought it
on a whim.

PCL seems recommended by a few people, so maybe I shouldn't have dismissed it
so quickly. I opened it up to several pages and saw large blocks of text with
very few line breaks, but maybe I just happened to turn to the wrong pages.
Perhaps I'll give it another chance.

Again, thanks for the advice everyone!

~~~
CaptainMorgan
silentbicycle also recommended the Little Schemer books. But for me
personally, while they may work for you or someone else... I found that they
didn't work for me. Not to say that I have a weight problem, but I love food
and food is the theme throughout these books. I like to watch my weight and my
sense of control with food is not that stellar; and about three-quarters of
the way through the book I realized I wasn't going to make it through to the
end or with the sequel: Seasoned Schemer. The food they use to bring their
concepts full circle just don't do it for me. Thus, I'm yet another one for
SICP or PG's book.

I always recommend Applications Programming in ANSI C by Johnsonbaugh if
you're interested in learning C. It's got a great scientific and engineering
theme.

While I'm not sure about your area of the world, I know that in my area books
at the bricks & mortar stores are ridiculously expensive. Thus, I always do my
book buying at places like Amazon and I suggest you do too.. especially if the
book you're looking for in the Borders store doesn't carry your desired book.
I find the stores like Barnes & Noble to be great places for eye candy...
exploring the books they have, sitting in their comfy chairs and making notes
on the books I'm going to buy online later. :)

Best of luck to you!

------
radu_floricica
For the beginning this and Practical Common Lisp will serve you well. Lisp
isn't that difficult at the beginning, once you go past the parentheses. But
soon you'll find yourself looking for an environment in which to do real
stuff. Here, if the obvious choices don't suit you, I suggest trying out
Clojure. It's a lisp, functional language, and it's 100% embedded in java -
meaning it's probably as fast or faster then most lisps, and it has arguably
the largest and best organized collection of libraries in existence.

~~~
jrockway
Except the libraries aren't very Lispy. I don't think you can program Clojure
without realizing that you are actually programming Java with realistic
syntax. (So basically, you need to be good at Lisp and Java. As a result, I
wouldn't recommend it for beginners.)

SBCL + SLIME is a nice development environment. CL is far from a perfect
programming language, but you can just ignore the stuff you don't like and it
comes pretty close.

