The long-overdue serious attempt at Lisp, part 1: which Lisp?

This is a blog about being a reinvigorated programmer.  So it’s ironic that the most successful articles so far (at least in terms of number of hits) have been about The Good Old Days — Whatever happened to programming? and Programming the Commodore 64 being two examples.

One possible response to this would be to change the blog title to The Nostalgic Programmer, but I’m not going to do that — despite what you might think from what I’ve been writing, I am actually looking forwards more than backwards, and there are plenty of things I am excited about right now, including Ruby, refactoring, REST, Rails and even some things that don’t begin with R.  Lisp, for example (although I guess I could have squeezed that into the R-list by substituting “recursion-based languages” or somesuch).

I’ve been promising since the second meaningful entry on this blog to learn Lisp, and it’s time to get started seriously.  But before I do, I have an important choice to make:

Which Lisp?

Perhaps because of its very long history (it was first specified in 1958), Lisp has become horribly fragmented, and exists in far more mutually incompatible dialects than any other language.  Not only that, but most of the dialects have multiple incompatible implementations, too, so you can’t just “learn Lisp” in the sense that you “learn Perl”.  You have to pick one.

And that’s where I’m asking your help.  I know that some of you out there have a lot of experience with Lisp, or rather, Lisps, and I’d really appreciate your input as I try to make this initial decision.

People generally say that the two principal dialects that you have to choose between are Common Lisp (big, kinda ugly, has comprehensive libraries) and Scheme (small, elegant, deficient in libraries) — and that the former is the best choice if you want to actually get stuff done but the latter is better for educational purposes.  On that basis, my bias is towards a Scheme: I don’t particularly expect to use Lisp for any of my actual work (although if it turned out that I did, that would be a bonus), but I want to learn it primarily to become a better programmer.

There’s a third option as well, though: Emacs Lisp.  GNU Emacs has been my primary editor since 1987, and I don’t see that changing any time soon.  So knowing Emacs Lisp would be of more immediate practical value to me than either Common Lisp or Scheme.  Does that seem like a reasonable path to take?

Which Scheme?

Also, supposing I choose Scheme: that still leaves the question of which implementation.  Looking at the list of packages provided by the operating system of the computer that I’m writing this on (Ubuntu GNU/Linux 9.10), I see:

drscheme – PLT Scheme Programming Environment – transitional package
mit-scheme – MIT/GNU Scheme development environment
mzscheme – PLT Scheme Interpreter – transitional package
plt-scheme – PLT Scheme Programming Environment
scheme48 – A simple, modular, and lightweight Scheme implementation
scheme9 – Scheme 9 from Empty Space R4RS Scheme interpreter
sigscheme – A Scheme Interpreter
tinyscheme – Very small scheme implementation

That’s a lot of choice.  And on my other computer, running MacOS ports, I am offered even more:

bigloo – Bigloo is a fast Scheme implementation.
chicken – Compiler for the Scheme programming language
elk – Scheme Extension Language Kit
gambit – Gambit-C is a fast Scheme implementation.
gauche – A script interpreter based on Scheme
mit – MIT/GNU Scheme
mzscheme – MzScheme is an implementation of the Scheme programming language
scheme48 – Scheme byte-code interpreter
sisc – Second Interpreter of Scheme Code
sketchy – interpreter for a purely applicative dialect of Scheme
stklos – free Scheme system supporting most language features from R5RS

Even if I narrow it down to the versions that are easily available on both platforms, that still leaves MIT Scheme, mzscheme, and scheme48.  How do I choose between these?

Help me, Internet: you’re my only hope.

P.S.  No thanks, I don’t want to learn Haskell instead

Nor Erlang, nor Clojure, nor OCaml, nor any of the other more whizzy and spiffy modern functional languages.  I am sure they are all great, and have many important advantages over Boring Old Lisp; but at this stage, I want to start with foundations, and that means the language from 1958, not one of these fashionable arrivistes.

Their time will come.

About these ads

37 responses to “The long-overdue serious attempt at Lisp, part 1: which Lisp?

  1. PLT Scheme is available natively as an app bundle on OSX. Mzscheme is just PLT Scheme without the IDE and the GUI libraries. I wouldn’t recommend using it.

    I would definitely choose PLT, there are schemes offering better performance, but no other offers the same library breadth and quality.

  2. PLT Scheme is a great option, it (and the IDE DrScheme) is the variant used in the excellent book How to Design Programs.

    This combination of book and scheme dialect is often compared to the even more famous book “Structure and Interpretation of Computer Programs” which uses MIT Scheme.

    Depending on how you learn one or the other may better suit you. The differing approaches have been written about in a paper called “The Structure and Interpretation of the Computer Science Curriculum” available at http://www.cs.brown.edu/~sk/Publications/Papers/Published/fffk-htdp-vs-sicp-journal/

  3. The language that you’re looking for, Lisp from 1958 is probably more similar to to LISP 1.5 than to more modern languages like Common Lisp or Scheme.

    Being Schemer myself, I of course also prefer Scheme to CL. Before beginning to learn Scheme you should be aware that the current Scheme “standard” R6RS is now well adapted in the community and while there are a number of high-quality R6RS implementations, many are going to stay with R5RS and maybe migrate to R7RS.

    Whether you choose R5RS or R6RS does not make that much of a difference, though, both have the standard documents and TSPL3 or TSPL4. Though I’d recommend you to choose a Scheme that is in active development like Mz, Larceny, Ikarus, Mosh, Guile, Gambit-C or Bigloo, preferably with an active mailing list where you can (and especially in the beginner-phase should) ask questions.

    Personally, I use PLT Scheme (Mz), but keep in mind that PLT, while being a good implementation it has really a lot extensions to Scheme which turn PLT more into a Scheme dialect on its own than a Scheme implementation. Still, it has the most extensive documentation and a friendly mailing list.

  4. I would certainly recommend plt scheme for it’s libraries and ide.

    If you want something smaller (extension language) then you might prefer guile.

  5. I’d definitely encourage at least giving Clojure a try — it’s a non-Common Lisp, non-Scheme Lisp-1 (i.e. functions and values share the same namespace, unlike Common Lisp’s weird approach) focused towards concurrent programming. Closest thing to Haskell I’ve seen in a dynamic language — infinite sequences, optional lazy evaluation, etc. And amazingly scalable.

    http://clojure.blip.tv/

  6. If you really want Lisp as it was in 1958. Then my Lithp project could use some more core implemented. Have fun! ;-)

    http://github.com/fogus/lithp

  7. Clojure; ’nuff said.

    On a more serious note, Clojure is _the_ Lisp to learn today.

    It’s pragmatic, amazingly well designed, has some great concepts and runs really fast.

    Note: Ex-professional Common Lisp programmer and Scheme hobbyist here. Switched to Clojure for real world programming last year and haven’t looked back since.

  8. So, Michel S. and Baishampayan Ghose, you’re telling me that Clojure IS a Lisp? In the same sense that Jython is a version of Python, or are you making a fuzzier statement along the lines that, say, C++ could be argued to be a version of C?

  9. Clojure, definitely. It’s a modern Lisp which actually has a concurrency story. And you’ll enjoy the gazillions of Java libraries that you can immediately use.

  10. “And you’ll enjoy the gazillions of Java libraries” … I’m not sure whether I’d consider that a feature or a bug.

    (Don’t worry, I’m only joking. Probably. Mostly. HHOS.)

  11. Common Lisp and Scheme were each standardized (separately) in the 1990s, emerging from a sort of Cambrian explosion of lisp dialects in the decades before. As lisps, they are vastly different from the prototypical and long-obsolete language of 1958, and even each other. Subsequent incarnations of these dialects (in the form of implementations, libraries, and updated standards) serve to distinguish them ever more.

    While CL or Scheme are well-defined, the question of what makes a lisp in the general sense (or how any individual dialect measures up) is rather nebulous, and probably of little consequence.

    Clojure’s lispy nature is strong, but still different. In some ways it is arguably a logical advancement of the lisp idea, perhaps as Common Lisp or Scheme were (for examples, see Clojure’s generalized sequences, and also its quotation semantics.) Intuitively, Clojure is obviously a lisp.

    That said, you would do well to begin learning any of these three dialects. It might not matter which you started with, because I’d wholly recommend exploring all of them; their differences make this approach worthwhile, while their similarities make it easier on the whole. :-)

    Emacs Lisp will be immediately more useful, but may prove to be less enlightening in the long-term. (Incidentally, I began this way, and in hindsight I would rather have learned Common Lisp first.)

    If it helps, I have written some advice relevant to learning Common Lisp, here: http://abhishek.geek.nz/docs/lisp-answers/ — some of it may apply to other dialects too.

  12. Lisp closest to the spirit of 1958 is just the newcomer: Clojure. Like others revolutions, is based in a back to the essence of roots.
    Scheme did it in 70’s, but Clojure is doing now.

  13. To put it nice and short: Take a look at all of them (CL, Scheme, Clojure). They are all worth knowing, and you won’t be able to make a choice until you have at least played a little with all of them.

    Because you’re an Emacs user, and probably don’t care much about IDEs like DrScheme, a selling point for CL might be SLIME. Yes, you can also use Cljure and some Scheme dialects from within slime, but so far nothing beats SLIME+CL. Since you will (if you follow my suggestion) learn about all those Lisps anyway, maybe you should go with the one that is best supported in your environment of coice.

    As far as Emacs Lisp is concerned: Plowing through (info “(eintr)”) is something that can be done in a weekend. That won’t make you an Emacs guru, but it’ll suffice to get started. Emacs Lisp might not be the greatest language on earth, but as an Emacs user, you’ll really benefit from it.

  14. You shouldn’t view Lisp as a language with various dialects — but as a family of related languages. It’s old enough that “dialects” like Emacs Lisp and Common Lisp are pretty different languages. In particular, Scheme is itself something that should be considered a family of languages in its own right, all related by a very small core specification.

    As for the choice of a language to learn, my obvious choice would be PLT Scheme — obvious since I’m one of the PLT hackers… But to get a little more focused on the question of a language to learn, PLT has good documentation (docs.plt-scheme.org), including materials that are intended for learning the language, not just reference manual. For example, the first few entries on the documentation page are guides that are tutorial-like documents that will quickly introduce you to the language, including systems programming and working with the bundled web server (which has enough features that you could certainly use to get some “real work” done with it). These are also included with most PLT Scheme installations (and for that I recommend using our installers over the outdated version that you’d find in Ubuntu…). In addition to these, there is the HtDP textbook (htdp.org) that uses PLT Scheme (but this might be too slow for your taste) and the well known SICP — which can be a lot of fun but is outdated in several places. (If you do choose PLT and read through SICP, then see the support for it at http://www.neilvandyke.org/sicp-plt/ — it would simplify going through the book.)

    And about the choice of Scheme or Common Lisp or Emacs Lisp or Clojure — Scheme, and in particular PLT Scheme comes with a unique set of features that makes it very easy to extend the language in a way that no other Lisp dialect can do. But unsurprisingly, this is not something you’d run into as a beginner. Emacs Lisp might be useful to learn if you live in Emacs, but from a new language point of view it doesn’t have much to offer. Clojure can be very modern in some aspects (like concurrency, and its approach to data structures), yet in others it is disappointingly the same as older lisps (unhygienic macros, dynamically scoped variables, tail calls) — but saying so will probably lead to some flames… Comparing Common Lisp to (any) Scheme leads to even more flames — so it’s probably best to just skim through a bunch of sites yourself and choose one. Learning one of these is a much better use of time than reading through such flames…

  15. Randy Hudson

    If you do decide to take a closer look at Clojure (which I strongly encourage), there’s a couple of resources I’d like to recommend.

    The official web site is http://clojure.org. Browsing around a bit will give you an idea of language, how it’s like and unlike other Lisp dialects.

    Stuart Halloway’s book ‘Programming Clojure’ is an excellent survey of the language.

    Finally, no Lisp discussion these days seems complete without a link to this cartoon: http://xkcd.com/297/

  16. Why do you poo-poo Clojure, but you are considering Scheme? They’re both dialects of LIsp.

    I know you have some weird deal about “getting back to the roots” of 1958, but Common Lisp is not the language of 1958. Common Lisp is the language of the 80’s or whenever it was ANSI standardized. Lisp (aka Lisp 1) and Common Lisp are different animals. I don’t even know if you can find a 1958 Lisp anywhere, and even if you did, why would you want it? It’s not going to eliminate any complexity or make things simpler. In fact it would be *worse*. This isn’t a case of first principles, it’s a case of a horse and buggy (*barely*) vs. a car with an engine and 4 wheels and all the rest of the bits you need to make it a useful transportation device.

    On the CL “dialect”/”which to learn” thing, I think you are confusing the language itself with libraries that you might find in some commercial implementations like Franz AllegroCL. The only reason you have to “pick one” is if you want to come out the gate with a ton of library support. They all implement the CL Hyperspec (the ANSI standard), and yeah maybe there are “extras” but these are usually in the form of macros, not extensions to the language itself. The situation is really no different than it is with any C compiler vendor. You get their compiler, and you get their libraries. Write to the spec/standard libraries (defined in the CL Hyperspec), and voila you have portable code. Use somebody else’s socket library and voila, now you have a dependency. How is that different from C? It’s not a language thing, it’s a library thing.

    Finally, don’t lump Clojure in with the ASCII art functional languages, or those abominations of pointless complexity like Haskell. Clojure is a Lisp dialect, period, end of story. It’s a well-designed language on a good platform (the JVM). You should consider learning it.

    I think this is one of those times when it’s best to start with the most modern thing and then go backwards to learn the culture, where the ideas came from, etc. Start in 1958, and you will most likely give up from sheer frustration before you reach 2010. Good luck.

  17. I’m just glad you didn’t mention AutoLISP.

  18. A general comment to you all: many thanks for what you’ve contributed to this discussion so far. I’m find it very informative, not to mention just plain fun.

    foo asked: “Why do you poo-poo Clojure, but you are considering Scheme”. For a very good reason: because of ignorance. I’d not realised that Clojure is a Lisp, but, rather, had it down as one of what foo amusingly calls “ASCII art functional languages”. I know better now, and Clojure is on my radar.

    Everyone, please keep the comments coming! I’m sure there is lots more to learn.

  19. You might want to look at this CL/Scheme comparison:

    http://community.schemewiki.org/?scheme-vs-common-lisp

  20. PicoLisp is the one I chose after looking at but not getting into CL, PL kicks ass.

    Homepage: http://www.software-lab.de/down.html

    What you can do with it: http://www.prodevtips.com/2010/03/20/how-to-write-a-big-app-in-an-obscure-lisp-dialect-you-dont-know/

  21. Arild Haugstad

    You might be running a different Ubuntu GNU/Linux 9.10 than I am, but somehow, I get the impression that your list of available Scheme-implementations only include those where “scheme” is part of the package name…

    Of those you mention as available for MacOS, the “universe” repositories appear to include at least chicken (chicken-bin), elk, gambit (gambc) and gauche…

    And there’s also scm, guile (guile-1.8, guile-1.6), stalin and scsh…

  22. Arild, you are completely right: not knowing the names of all the other scheme implementations, I only looked at packages whose names contain the string “scheme”. It wasn’t meant to be an exhaustive list!

    I guess it’s good that those eight other Schemes are also available …

    Ugh.

  23. foo, you said “I don’t even know if you can find a 1958 Lisp anywhere”. Well, you could try McCarthy’s original paper, which implements a Lisp interpreter in Lisp. That’s the oldest I know of, although Lisp is older than the paper: eval was a relatively late addition.

  24. At the risk of being horribly flamed and fed to the trolls, have you considered newlisp? (http://www.newlisp.org)

  25. To understand the most basic core of Lisp, it helps to start with Paul Graham’s complete demonstration of the mathematical basis of Lisp in a dozen pages, The Roots Of Lisp (note: in PostScript). It is strongly recommended. McCarthey’s fifty-year-old paper is good, too, but not exactly what you want unless you like history. Steele and Gabriel’s history is nice also if you really do want history.

    Paul Graham’s On Lisp is free to download and an excellent somewhat advanced manual.

    Common Lisp, Scheme, and Clojure are all fine and have many similarities. I like them all. The brilliant Lisp macro system is available for almost all of them, though some Schemes prefer the toy ‘hygenic’ macro system that is much less powerful.

    Don’t forget to use EMACS Lisp and GIMP Scheme scripting, too. I wrote my first Lisp code in the GIMP.

  26. Emacs Lisp, for sheezy. It’s great for getting started as a hobbyist / dabbler. Some of the comments above seem to assume you want to focus maniacally on Emacs (versus playing around with it and seeing if you like it).

    Advantages of Emacs Lisp: fully integrated environment with great browseable docs, debugger, and a complete app to work on and extend (ie. Emacs itself). Plus, you already have it!

    Some ancient Elisp code I wrote (for illustrative use only :) http://github.com/jm3/krunk-emacs

  27. Adam Koblentz

    Having had Eli as a teacher at NEU and learning PLT Scheme from Eli and Matthias, I can say that PLT Scheme is an elegant language with great extensibility. I do not believe you’ll miss out from not using the MIT Scheme and maybe you’ll even gain a few things. :)

  28. If you go with Scheme, you can enjoy working through The Little Schemer, which is a really fun (and funny, and concise) book. I know you’re a fan of actual printed books, and this one deserves to be a classic.

    As for implementation, I arbitrarily chose Guile because it was already installed. Like you, I wasn’t trying to get anything in particular done, I was just hoping to learn something. Guile has some minor syntactic differences from the examples in the book, but nothing I couldn’t work out easily.

    (It was also fun to poke around in the interpreter and see how many functions you define in the book are shipped with guile.)

  29. If you are not so hung up on being ‘real standard lisp’, and you use a mac, have a look at impromptu http://impromptu.moso.com.au/

    It gives a nice environment for using scheme for both graphics and sound.

  30. After reading these comments all I can add is; Oh. My. God.

  31. Pingback: The long-overdue serious attempt at Lisp, part 2: is Lisp just too hard? « The Reinvigorated Programmer

  32. IANALP (I am not a lisp programmer), although I have read on it and do want to learn it. What about Paul’s new flavor arc? http://www.paulgraham.com/arc.html

    You could get in on the ground floor of maybe the next big dialect? Although that goes for Clojure too.

  33. Arc’s syntax is horribly counter-intuitive to any Lisp/Scheme programmer (= for assignment, which is really dangerous when other Lisps use it for equality testing), and I really don’t see what it brings to the game. Esp. when it does not even have a real implementation yet.

  34. If you don’t *want* to learn those other languages, fair enough. That’s your prerogative. But if your justification for your language choice is about “fundamentals” rather than just preference, that’s a different story.

    I’d agree about Scheme in the sense that it is the “semantic assembly language”, analogous to how assembly language is the low-level language of hardware, not semantics. You get to write programs on the level of your own syntax tree and syntactic abstraction, and that’s powerful.

    However, there are more to “fundamentals” of programming than just programming languages. Software is meant to solve problems, and program-oriented thinking is not the same as system-oriented thinking. To me, 99.999% of all languages focus on making a language that encourages perfect software: a language that prevents all errors, is easy to understand, is lightening fast, etc.

    But the most interesting question I’ve heard in all of programming was asked by Joe Armstrong: How do you make reliable software in the presence of software and potentially even *hardware* errors? Most languages never ask the question, or simply shrug it off as being outside the scope of the responsibility of a language. But to me, I think that is an implied requirement for all software! Reliability isn’t about perfection (that most languages strive for, such as perfecting sophisticated typing or being more “pure” functional/OOP/declarative) it’s about *fault-tolerance*. That requires a different way of thinking. There are requirements here that are non-negotiable.

    To me, the two “fundamental” languages are:
    1. Scheme, to learn the structure and interpretation of all *programming* of software
    2. Erlang (for now due to lack of other candidates), to learn how to create *software systems* that are fault tolerant. You don’t automatically get that from Scheme, or from the approach of the structure and interpretation of code, hence why I pick these *two* languages.

    Notice I didn’t say “concurrency”. All the “Erlang-style concurrency” hype you hear about in other languages 100% absolutely misses the point. Concurrency is just one requirement on the way to fault-tolerance, the real goal. I highly suggest reading Joe Armstrong’s PhD thesis on Erlang’s website.

    Lest you think I’m just promoting Erlang as a fanboy, etc. I’d like to mention that actually Python is my favorite language, but there is a real reason why I mention Erlang here: “fundamentals”. Fault-tolerance and software *system* architecture (NOT program architecture) are best learned in Erlang, among the currently existing languages. Algorithms, data structures, flow of execution, or best learned in something like Scheme.

  35. Thanks, RobW, that’s interesting stuff. Appreciated.

  36. David Dreisigmeyer

    You could try Kawa ( http://www.gnu.org/software/kawa/ ). It’s a Scheme implementation that can also call Java. So you could learn only Scheme and then add in Java if you’d like later. Also under active development. The interface to Java seems as convenient as Clojure’s also.

  37. Pingback: Tagore Smith on functional programming | The Reinvigorated Programmer

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s