Ask HN: What makes Lisp hard to learn?

13 points by francoisdevlin ↗ HN
I'm interested in producing educational material on how to use a LISP. What are the major pain points on the learning curve for everyone? Specifically, what's tough to get coming from a Java or C# background?

Share your stories!

8 comments

[ 5.5 ms ] story [ 38.8 ms ] thread
The hardest thing is the lack of a "batteries included" standard package. There are competing implementations (which all have strengths and weaknesses) and lots of libraries (many of which are good, few of which are widely accepted as "standard").

The short answer is to setup SBCL and Slime/Emacs (here's a guide I wrote: http://www.pchristensen.com/blog/articles/installing-sbcl-em... )

A previous discussion on learning Lisp: http://news.ycombinator.com/item?id=125766

Plus another article I wrote: http://www.pchristensen.com/blog/articles/how-to-learn-lisp/

Additional resources:

SLIME/Emacs cheat sheet: http://www.pchristensen.com/blog/articles/public-beta-open-f...

Watch the SLIME movie (http://www.guba.com/watch/3000054867 ) and read my notes on it (http://www.pchristensen.com/blog/articles/reference-for-the-... )

EDIT: To avoid the setup hassle entirely, try Thnake (http://jasonfruit.com/thnake/ ) - a Linux liveCD with SBCL/SLIME/emacs preconfigured, complete with webserver and gui packages.

I note that the poster described a Lisp and not specifically Common Lisp. Clojure at least has plenty of batteries available via its Java interoperability. The biggest thing holding Clojure back at the moment appear to be installation, building other people's projects, and IDE setup.

I don't know if Clojure is a helpful suggestion to the OP but it is certainly a more appealing way for me to get into Lisp than Common Lisp was.

Edit: I have just recently completed the install/build/IDE trifecta myself thanks to ELPA and leiningen but it certainly wasn't a one-day process. One of my biggest problems was reading out of date tutorials rather than the latest and greatest. It can be hard for a newcomer to see a HOWTO blog post from mid 2009 and decide whether or not to try it out.

I can do an SBCL/emacs/SLIME setup in 15 minutes or so, but I've done it a bunch of times. Someone following my guides can do it in ~1 hour.

I'd love to try out clojure, but I want to type something like 'sudo apt-get install clojure-sandbox'.

Leiningen actually isn't that far from being exactly that. It's not a one-liner, but setting up a scratch project that'll give you a repl is very straightforward. Setting up swank is only slightly less simple because you've got to edit a config file. It can be difficult to figure out the right incantation for that because the docs are pretty nonexistent, but google is helpful enough there.
ClojureBox provides what you ask for, but it's windows-only. To get up and running in Ubuntu you'd have to do the following:

  sudo apt-get purge openjdk*

  sudo apt-get install sun-java6-jre sun-java6-jdk git-core

  wget http://github.com/technomancy/leiningen/raw/stable/bin/lein

  lein self-install

  git clone git://github.com/relevance/labrepl.git

  cd labrepl

  lein deps

  script/repl

  elinks http://localhost:8080
Edit: To get emacs you'd want to use ELPA to install swank-clojure. The apt commands were lifted from Lau Jensen's video tutorial: http://www.vimeo.com/8398020
For me, coming from java, macros and closures were the two concepts that were completely alien and made a huge difference. Java provides a lot of structure (packages, classes, interfaces) that result in a lot of reassuring boilerplate code. If you're using lisp for conciseness, there is no boilerplate to comfort you, to signal where you are and what you should be doing at this point in the code.
Hmmm, I started learning it in 1979 (sic) when my major experience was FORTRAN, BASIC, and an obscure language called PPL who's major features I hadn't taken advantage of (it was for a summer class). I'd toyed with/looked at COBOL, PL/1 and C.

The biggest thing, I think, is that it's based on expressions rather than statements, which is rather a different model than the Algol family (more or less) languages mentioned above. And for me, learning the importance of indentation for code comprehension, but that had already started with my learning C.

And then there's recursion; you can't do idiomatic LISP without it (The Little Lisper or nowadays Schemer is good for that).

Ideally you'll also learn functional programming; optional in Common Lisp, hard to avoid in Scheme, and there's little point in using Clojure without it.

Frankly, I find it delightfully simple. The conceptual base is small, the syntax of parens, atoms, immediates (e.g. numbers) and special forms (e.g. if) makes is a very regular language, no "cancer of the semi-colon.

It's really quite nifty, and of course back then there was pretty much nothing faster with which to develop software. You mostly just have to unlearn some stuff and be willing to put in some effort, which will be well rewarded.

I come from a C/Unix shell/Perl background mostly (with a sprinkling of Java). The main stumbling blocks that I found were:

1) oddly-named functions -- rplaca, cadaddaddr and the like

2) weird "macho" indentation -- more so than the much-maligned parens. I found that at some points of The Little Lisper, I needed a ruler to make sense of the indentation level. I have hopes that the default 4-column indentation in Clojure will make it much easier for me to learn.

3) strange control flow constructs. Trying to make sense where the condition, if and else clauses begin and end in an "if" can be a pain. More so for "cond" or "do". Combine that with 2), and things become unreadable quite fast.

By the way, none of these would be a showstopper if I had to learn Lisp for work or college. Just that, they made it not worth my time to try to learn it for fun.

Edit: I forgot, tail-call recursion. A single misstep and your CPU and memory footprint go from constant to exponential and/or Ackermaniac.