In the spirit of my last post, I decided to turn one of my favorite long comments on Hacker News into a blog post in the hopes that someone would find it useful. There was a good discussion last week about how to learn Lisp, and since I was a little late to the thread, most of the things I wanted to say had already been said. So, in an effort to pull it all together, I made a nice long summary comment, which is reproduced and cleaned up below.
Before I started learning Lisp, I have (in reverse chronological order) worked with .Net for several years, disliked C++ in college, loved Pascal in high school, dabbled in (Assembly?) programming my TI-82 graphing calculator, and started with Hypercard. Here’s my advice based on ~1 year of part-time Lisp education.
- To learn “lispiness”, functional programming, and get a feel for the computational approach to programming, read The Little Schemer and The Seasoned Schemer. Also, use the resources for the MIT Intro course Structure and Interpretation of Computer Programs. Watch the video lectures (30 well spent hours) and if you’re ambitions, read the book (Amazon). Doing these things will help keep you from writing PHP in Lisp.
- To put it into practical perspective and learn the nuts and bolts of modern common Lisp, read Practical Common Lisp (Amazon).
- If you read PCL, you will run into Emacs and SLIME (the generally preferred [NO FLAMES, PLEASE. I KNOW VI IS AWESOME TOO] open source way to edit Lisp files). I wrote some resources to help with that:
- I’m surprised no one has mentioned PAIP (Peter Norvig’s Paradigms of Artificial Intelligence Programming). Probably because there’s no free version online and it’s a pricey book. I got it for myself for Christmas and it’s well worth the price. It’s half AI book, half tutorial on Lisp programming and Lisp style. It’s a good read with lots of example programs written in good Lisp Style.
There are three hurdles people usually run into when learning Lisp:
- The language looks different – this goes away with practice and familiarity. It starts looking normal fast. The parentheses are a bit tough to manage unless you use a capable editor, which leads to:
- Emacs is different – really powerful, fun to use, but it takes investment in learning. It’s really tempting to quit when starting, but worth getting over the hump. Once you do that:
- The way of thinking is different in Lisp – Lisp seems a little awkward to use until you get (don’t need to master them, just get the idea) the following ideas: 1) code can be manipulated as data because the syntax is so simple, 2) creating your own syntax (using macros – code that writes code) means that you can express your program in a way that closely matches the problem you’re trying to solve. Some good articles to help get these points are:
Don’t worry if you don’t get these “big picture” things at first, they click at some point and everything makes a lot more sense. You can speed that up by putting a lot more Lisp in your head in the meantime.
Does anyone have any more tips on learning Lisp?
Also: read comments on this post at comp.lang.lisp, reddit, Hacker News
TheGZeus says
Hmm, I understand that Emacs is the preferred method of working with, and the fact that it’s core is a text editor makes the next step “HEY!!! What about VI!!!???” but why does NO ONE seem to know about Eclipse/Cusp?
I’d have been actually DOING REAL PROGRAMMING by now if someone had told me about this sooner…
I started out using AppleLogo to draw weird images, fractals and weird recursions on a //c and did basically nothing for 12+ years because no one ever bothered to tell me that programming is for people, not ‘programmers.’
Yes, Cusp can do everything SLIME can. It can do more, from what I can tell. Granted, you’ll need to know how to extend it if you want to…
Peter says
True, cusp/eclipse is sort of the unwanted stepchild of Lisp editing, because it’s fairly new, it’s not part of a holy war, and the cool kids (Yegge et al) have nothing nice to say about Eclipse. Having said that, it’s probably an easier transition, especially coming from Java or .Net/Visual Studio.
I decided to go with Emacs over Eclipse because while Eclipse would probably make me more productive in the short run, I was jealous of the old hat Emacs guys and the great stories they tell. I’m looking 1-10 years in the future and I think that over that period, the time I spend learning and extending Emacs will payoff more. That’s one luxury a day job provides!
Phil says
As someone mentioned CUSP, I thought I’d mention my own pet project ABLE (http://phil.nullable.eu/). A lot of newbies have told me that it helped them to start learning CL where they would otherwise have been put off by Emacs. Of course, you can always move on to SLIME at a later date when you’re comfortable with the language.
she says
To be honest, we are all kinda a victim to the vim vs emacs wars in the past.
It was a reason why Eclipse, as slow and bloated as it may be, won.
I dont like Eclipse but I endorse it as a cross-plattform solution with a GUI. Not everyone wants to learn either vim or emacs (i gave up on vim after 2 years, and emacs i gave up after 3 weeks. I simply felt that the few things I’d really need are scriptable tasks which shouldnt be specific to any editor anyway…)
TheGZeus says
The reason I mention Cusp everywhere is the main complaint I see from people who don’t com off as (pardon my french) assholes is NOT the syntax, it’s the fact that you’re stuck with Emacs or you’re up the creek without a paddle.
Not only that, but people who ask why often get something akin to “why would you want anything else? Emacs can…” response.
I know a professional programmer who’s done professorships and contract work for the US government. He uses Vi for quick little scripts, but anything that requires alot of work, he uses Eclipse or another major IDE. I wish I could remember the other IDE. He uses a Mac, but it’s not Xcode, as I think he’s doing mainly cross-platform…not that you can’t do that in Xcode…maybe it WAS Xcode… I digress.
Books on Eclipse are often the same thickness as the O’Reilly Emacs book, and cover a large portion of basic Java programming as well.
Emacs is a powerful program, but it’s, at the least, intimidating the a beginner (like me) and we need more beginners in the Lisp community. Much like Freemasonry (of which I was a member until I became an atheist and left) it gives off the impression as being ‘uncool’ or ‘a bunch of weird old guys.’ People may rightfully dislike the idea of using ‘cool’ as a selling point. The kids who gave me shit in high school were ‘cool’ at the time (they push shopping carts and never smile now), but the sad fact is that if you get 1% more CL users that way you might get another 2% who now have confidence in the libraries etc.
Communities are subject to flock/pack/school(fish) mentalities, to a degree. Might as well get as many users as possible.
Again, I’m not here to bash Emacs (though I’m a kate/vim user for the most part), I’m just suggesting that we start promoting the use of Cusp/Eclipse to beginners and to people new to the language. I know someone who’s a great programmer, he used to program physical modeling of the oceans in C++. When I told him the main IDE for Common Lisp was Emacs he looked like I’d told him my family tree led back to a real tree.
Think of it this way: What’s worse, losing one person to the cult of emacs, or losing both that and a potential Lisper?
Anon says
I’ve found the best way to learn is to minimize the time spent on the computer. Try solving a problem using a pencil, spiral notebook, and reference book.
Writing and revising on paper allows more time to think, and the notebook lets you to flip between sections easily and resume after interruptions. It may take 20 pages of writing to get 2 pages of finished code. Then when you’re finished or stuck, test it or search the web.
After tackling some projects this way, you’ll have more interest and comfort to explore how to design it better next time or how to be more productive with new editors.
fendres says
My problem ist not learning Lisp. It is easy to understand. My problem with lisp is, that there seems to be no standard way. E.g. first I have to decide which lisp implementation to use. And if I want to solve complex problems in an efficient way, I need good libraries to do that. I do not want to reimplement linear algebra functionality, gaussian processes, computer vision algorithms, a visualy pleasing gui that fits nicely into my desktop environment and a lot of things more. So I would have to search everytime for hours to find something suitable (if at all).
Maybe here popular languages have an unfair advantage, because there are more people working on libraries and more people using it (which makes it easier to “follow the herd” to the good ones).
But my problem about lisp is definitely not the syntax or the programming environment. It is getting productive in a programming area where I have to rely on other peoples code. And keep in mind, that even though I learned the syntax of lisp and can write a program, I still lack the experience solving all the minor issues arising with libraries and implementations.
joe says
I went through the first 200 pages of PCL and discovered I couldn’t make minor changes to the sample code without blowing everything up. The problem was the weird semantics of macros, which look just like functions. I couldn’t just substitute things the way I would if it was all functions.
Here’s one thing I ran into:
CL-USER> (setf (slot-value *account* ‘balance) 1000)
1000
CL-USER> (defun fbalance (acct) (slot-value acct ‘balance))
FBALANCE
CL-USER> (setf (fbalance *account*) 1000)
; Evaluation aborted
So basically, you can’t just look at code using unfamiliar macros, and know by looking at it how you can fiddle with it. You have to learn the libraries just to understand the basic semantics of the code.
This wasn’t spelled out in PCL at all. So here’s what I think we need: some kind of tutorial that gives you the basics, and then pretty early on spells out in detail what you can and can’t do with various common macros, and why.
Telman Yusupov says
Nice summary, thanks Peter!
I took a slightly different book path to learning Lisp:
1. Read “Gentle Introduction to Symbolic Computation” by Dave Touretzky. This is one of the best introductory books for computer programming in any language (if not the best IMHO). It explains Common Lisp in a very clear way, it has a lot of exercises (with answers!) and several programming projects of higher levels of difficulty (with answers too!). The books is available for download from the author’s site for free.
2. Read Practical Common Lisp by Peter Seibel. After Touretzky’s book this one was much easier to go through, as I had a firm grasp on the fundamental concepts.
3. Paul Graham’s “ANSI Common Lisp” is a good one to finish the introductory book round. No new concepts after PCL and it took me some time to get used to PG’s programming style.
PAIP and “On Lisp” are on my to-do list.
To make the learning curve a little flatter and concentrate just on Common Lisp instead of going through Emacs AND Lisp at the same time, I’ve downloaded learning edition of LispWorks. It comes with a nice IDE on all platforms (I’m on Mac) that takes only several minutes to figure out.
Using LispWorks allowed me to go through Touretzky’s book without struggling with Emacs. Now I switched to using Aquamacs (Mac friendly version of Emacs) with Slime on top of Allegro (as I’m still learning, will go to SBCL later on).
Emacs is really powerful! I also use it for coding in other languages now.
My 2c…
Cheers,
Telman
Abhijith says
Gentle Introduction to Symbolic Computation is a good book for people who are new to programming or even functional programming for that matter.
Peter says
Nice! This is what I was hoping to get – angry people, skeptical people, enthusiastic people, frustrated people. Big thanks to whoever put this on reddit – I didn’t think it would resonate so much!
Phil, She, TheGZeus – I think I’ve seen the error of my ways. I’m far enough over the Emacs hump that I’ll stick with it, but at some point I’ll give Eclipse/Cusp a try to see where it fits on the continuum between Visual Studio and Emacs. I will also definitely recommend it to new users looking to tackle one thing at a time. Zeus, I definitely agree with you about the importance of increasing the user base. I’ve got a big post in me about that topic that I’ll write someday.
fendres – That is definitely a problem, one that I have some ideas about and have a bit of a plan for. I think the tipping point will be when one of the open source CL implementations works on Windows/Linux/Mac, and includes full threads and unicode support (I’m keeping an eye on the experimental SBCL Windows port). Once one of the implementations hits that point, it will become the de facto default and break down one big barrier for new users. The other important ingredient will be the right documentation, which is where I hope to make a contribution.
joe – OnLisp (Paul Graham’s second book) spends ~15 chapters on macros. He wrote it because in every other text, macros got only cursory treatment. It’s a free download in .ps or .pdf at http://www.paulgraham.com/onlisp.html or it’s online at http://www.bookshelf.jp/texi/onlisp/onlisp.html
Telman – Several people have mentioned GISC. I’ll have to take a look at it. It’s also a free download at http://www.cs.cmu.edu/~dst/LispBook/ so it should get more views (as opposed to PAIP). I’ll mention it more often and try to introduce its acronym (GISC) into the lexicon. Worked for SICP, AIMA, PAIP, and PCL!
Sesh says
“will keep you from writing PHP in LISP” – could you please explain this. My english is not that good.
Peter says
Sesh – There’s a saying that “You can write Fortran in any language.” (see http://www.codinghorror.com/blog/archives/000272.html ) This just means that learning the syntax of a language doesn’t mean much, you have to learn the new idioms and patterns that a new language lets you use. In the case of Lisp, this would be code-as-data, recursion, functional programming, symbolic computation, syntactic abstraction, etc. You could take a PHP (or VB, C, Pascal, etc) program and pretty much translate it verbatim into Lisp, but you’d be missing out on the best features that Lisp has to offer. Any new language you learn should change and expand the way you think about programming.
TheGZeus says
I looked back at my second post and… I come off as a dick, I think.
Just thought I’d apologise for being just kinda rude in general.
Not that I didn’t mean what I said, it’s just not all of it was relevant, and that can sound accusatory and ignorant.
…also ling-winded.
…I’ll be quiet.
Peter says
TheGZeus – Maybe a little crude, but I’m glad you said what you said. And about the long windedness, remember that this post was a comment somewhere else and I just cleaned up the links!
koolmoe says
+1 for GISC.
Having used Emacs for LaTeX editing in grad school, I personally prefer Emacs over Eclipse/Cusp. I have looked at Cusp, and it seems like it would be useful if I didn’t already know the basic key-bindings to be effective in Emacs.
One of the things I found useful in learning was to attack Project Euler type problems in Lisp. A good resource I found indirectly through lispjobs.wordpress.com were the problems on streamtech’s job board:
http://www.streamtech.nl/site/problem+set
I’m not interested in a job there, but the problems were fun to work on. I actually laughed out loud at how easy it was to solve some of them in Lisp compared to what I would have done in Java.
John Tobler says
The book, Structure and Interpretation of Computer Programs (SICP), recommended above, is available online for free here:
http://mitpress.mit.edu/sicp/full-text/book/book.html
It has been made available in connection with MIT’s OpenCourseware “6.001 Structure and Interpretation of Computer Programs” course:
http://ocw.mit.edu/OcwWeb/Electrical-Engineering-and-Computer-Science/6-001Spring-2005/CourseHome/
It’s free. Yes, it represents a nefarious scheme (pun fully intended) to turn you into an above average programmer. No excuses accepted!
TheGZeus says
http://xahlee.org/emacs/emacs_fun.html [EDIT: Changed to an accessible URL]
I agree with this, but mainly because I live in a persistent irony bubble.
I had planned to post this in my original post, but couldn’t find it. Just came down the Lisp/Scheme/Emacs Pipe.
Grant Rettke says
Folks new to Lisp should try DrScheme.
Glenn says
Another great way to learn SLIME and Emacs, if you use a Mac, is to download and install the Carbon version of Emacs. This is a port of Emacs to the Mac, with a Mac look and feel. It is _very_ nice. SLIME comes packaged by default, and what is really nice is that SLIME is a menu bar entry. You can find the SLIME commands in the menu, along with their short cut keys. I had been putting off learning SLIME/Emacs and going with Eclipse/CUSP (which is also very nice). Now we have 2 great choices.
You can find CUSP for Eclipse at:
http://bitfauna.com/projects/cusp/
and Carbon Emacs at:
http://www.apple.com/downloads/macosx/unix_open_source/carbonemacspackage.html
(or)
Their home page is:
http://homepage.mac.com/zenitani/emacs-e.html
Daniel Weinreb says
“Practical Common Lisp” by Peter Seibel is great. When we hire new hackers who don’t know Lisp, we just give them that. The other thing to do is find very good Lisp programmers and read their code. Lots and lots of code. Ask the writer questions like “why did you choose to do it this way?” and “what is this construct for?”.
Common Lisp is a lot easier to learn than many people think. Of course, being a virtuoso takes longer, but that’s true in any language.
Joe says
This is a discussion forum that I’ve tried to find elsewhere: A bunch of people engaging with Lisp (some of us, like me, new to the language), and sharing their trials and tribulations as well as their successes and excitement. The comp.lang.lisp forum can be helpful sometimes, but frankly the level of discussion there is usually beyond my current comprehension.
I’m really quite new to Lisp — a classic “noob” — but I have to agree with Telman: GISC is an absolutely masterful book, and IMHO, the best way to introduce yourself to this wonderful language. I’ve found PCL to be confusing, although understandable after GISC; I definitely do not recommend PCL to start. Graham’s “ANSI Common Lisp” is a good book as well, but only after some experience and only after finishing GISC. I’m essentially following the same learning path Telman did (when I have the time to do so), and I’m finding that it works for me.
I also just began learning Emacs (I’ve done all my Lisp learning thus far inside Corman Lisp, which is a nice and friendly — albeit basic — IDE). Emacs is tough going, but I figure I’ll stick with it. BTW, the guidance you posted on getting Emacs, CLisp and Slime to work together on Windows was an excellent guide, just what I needed.
This is a nice, useful, low-key forum. I’ll check in often since I have so much to learn.
Best regards to all!
gopi says
required sample lisp programmes to learn easily
alphard says
Thank you for the articles, Peter, very useful! First I’ve started learning LISP more then year ago, but gave up it soon. I had a lot of problems with choosing framework and with it’s installation. Recently I read your installation guide which helped me to setup emacs with slime correctly!
Reading PCL and SICP I still have my second old trouble – I need some interesting problem to be solved with LISP, but the most part of examples and exercises I’ve already read in both books seems tedious to me and doesn’t motivate. I afraid to give up with LISP again because of it.
shishir says
Well I’d given up trying to learn lisp, primarily because I couldn’t find a book on lisp catering to
my taste. I know SICP,PAIP,PCL are great, videos are
available etc etc. But well I live in India,
watching videos over net is just too costly 🙂
the books are too costly again.
Don’t we have some book that is straight forward
something like KnR ‘C programming language’ and is comparatively cheap. I read parts of PCL, I don’t like the book primarily because I grew up on C/C++ and writing styles of books for those languages are quite different from PCL.
alphard says
shishir, I am C/C++ programmer too. OnLisp by Paul Graham is good alternative (available online), especially if you experienced in C++ STL and templates techniques. Also GISC (see above) maybe what you need – it is easy to read and relatively cheap.
PAIP book is too general, but PAIP video lections are great – many unobvious lisp idioms + good style guide at the same time.
John says
I was looking at learning lisp and was thinking about using clojure as this would mean not having to re-learn lots of libraries. Also I code in eclipse anyway and there seems to be plenty of support for doing project euler using clojure.
Can anyone enlighten me about advantages / disadvantages over using common lisp
Thanks
Niels Olson says
I’m on page 24 of the Little Schemer right now. I would say the first stumbling block is that most people are going to start with PLT Scheme or MIT Scheme, and the key to using ANY of the examples is the first footnote of the first example in the first chapter: you have to make sure to use the ==> ‘ <== notation. Pay attention to that. Because every example assumes your figured out that notational convention. There’s a lot of this that I can skip over, but that screwed me up.
rino says
i really hate editors that forces me to do keyboard calisthenics *coughEMACScough*.
any Lisp interpreter out there? i think with the complexity of learning Lisp there ought to be an interpreter that will allow us to play with the language rather than learning how to use the IDE and the editor before being able to do a “hello world!”.
Peter says
-rino – Every common lisp implementation comes with a REPL where you can play around all you want without any IDE. Just fire it up and type (format t “Hello world!”) and you’re good to go. The IDE makes things like paren-matching, indenting, debugging, cross-referencing, etc easier but if you just want to play around I can see why you’d avoid emacs. I’ve not used them but I’ve heard good things about the Cusp plugin for Eclipse (http://bitfauna.com/projects/cusp/) and the ABLE editor (http://phil.nullable.eu/)
memoire pour imprimantes says
Any place for readymade lisp program coding.
Rui says
I think resources for beginners are a little complicated, specially because most of them (us) have a background related to C/C++ or Java (or something like those). Other negative aspect is not having a “standard” IDE “ready-to-code”, of course there is Emacs but the fact is most of the people today don’t have experience with it and it would difficult things. Cusp would be a great help, but it would be nice having more tutorials about it.
So, to finish, I think it would be great creating some sort of community focused on writing quality tutorials/documents to help newcomers (as others too) learning Lisp. Anyone else feels it can/makes sense be created?
Sara Bruce says
Great!,
Decent to be here.Superb work buddy.
Paul says
I’ve gone through quite a few of the old 1980’s and earlier Lisp and Scheme textbooks like Touretzky,Winston,Wilensky,Tatar,Little Lisper,Little Schemer, etc. and since around 2001, tried several implementations like PowerLisp and X-Lisp. I also tried out the online ELM-ART tutor. Most of these will bore one to death with “basics” about atoms, CAR,CDR,S-expressions and matching parentheses before you ever get to how to print something to the screen.
So, I really liked the practical ‘roll-up-your sleeves-and-let’s-start-programming’ approach in Practical Common Lisp (PCL) and getting CLISP/Slime/Emacs up and running on a Windows OS was a breeze with LISPBOX. I also liked the modern practical projects in PCL. However, I strongly dislike the dated,1980’s, command line Slime/Emacs interface. The worksheet idea in PowerLisp on Mac OS seemed much better and easier to work with. But overall, one seems to be climbing a hill. PowerLisp (MAC OS) is now obsolete (Buy Corman Lisp) and TLISP source code from the 1980’s has to be converted to Common Lisp etc. and new languages like Python have all kinds of modern extensions and libraries that are hard to find for LISP.I even hear Yahoo! Stores programmers converted LISP source code to C++ because they understood C++ much better than LISP.
http://art2.ph-freiburg.de/Lisp-Course
http://www.mars.cs.unp.ac.za/lisp/
http://reed.cs.depaul.edu/peterh/Tools/lisptutor.html
http://www.lisp.org/alu/res-lisp-education
http://computers.idoneos.com/index.php/Programming/Languages_%26_Tools/Lisp
http://www.franz.com/newtolisp/index.lhtml
http://www.cormanlisp.com/
Saurabh says
Dear Peter,
How can one learn Lisp, with the only knowledge of language C, in windows xp/7 environment?
thanks in advance
Peter says
Two ways I would recommend if you’re a complete novice:
Hope that helps!
human mathematics says
I get that it’s “good” to learn Emacs or Vim, but it’s not necessary to do that to learn Lisp.
Dean High says
Excellent posting. Thanks for writing.