102

I know there are a few different dialects of Lisp. Having decided that learning Lisp would be a new intellectual experience, I would like to know which Lisp dialect to learn, and why.

Is there one which is more popular than the others? Is any one of them more "complete", as in, better documented and supported? What are the pros and cons of this dialect?

tshepang
  • 12,111
  • 21
  • 91
  • 136
Humphrey Bogart
  • 7,423
  • 14
  • 52
  • 59
  • 1
    Duplicate: http://stackoverflow.com/questions/563356/which-lisp-should-i-learn – Greg Hewgill Jun 17 '09 at 19:51
  • I did a search on that before I asked this but the nature of the question evolved as I was typing it. I will ensure not to reinvent the wheel. – Humphrey Bogart Jun 17 '09 at 20:09
  • So what's the difference between this question and the one Greg mentions above? – cjs Jun 20 '09 at 02:53
  • 2
    I think, what he was trying to say was: When I first formulated my question in my mind, it was completely different from the current one, and looking at the questions in the related search didn't reveal any that fit what he wanted to ask. But by the time he typed out the question, it had changed and thus arrived on SO in its current form, which was asked previously. – J. Polfer Jun 20 '09 at 19:12

9 Answers9

86

You want to look for a balance between simplicity and cleanliness, attractive features, and a platform that will allow you to write interesting and useful software (to yourself) as well as serve as a learning tool. (This last will keep you going and learning for a lot longer.) Here are some possibilities:

  1. Scheme. Probably the cleanest of all dialects. This is no doubt why The Little Schemer was translated from LISP into Scheme. The fifth Scheme standard specification, R5RS, is a wonderful education in and of itself; it may be the nicest language and library specification I've ever read, as well as the shortest that's reasonably comprehensive. The PLT Scheme (now Racket) platform includes a fairly decent interpreter and compiler, is good for scripting, and also has some visual tools that make it excellent for learning.

  2. Common Lisp. Probably the most portable and comprehensive variant, this is most likely what you want if you want to be writing things such as commercial software. The standard defines extensive libraries, and many more are available beyond that, it has CLOS, which will probably teach you more about OO than any OO language could, and some of the compilers are very good. Disadvantages include some warts that Scheme doesn't have (such as having a separate namespace for variables that refer to functions), not being as clean and simple (as is the case with anything that has had to have the extensions and make the compromises necessary for large applications in the real world), not having hygienic macros, and emphasizing recursion much less than Scheme.

  3. Clojure. This runs on the JVM, which may give it a leg up right there for Java developers. It's got a few warts (e.g., you must explicitly ask for tail call optimization, though this may change one day if TCO is added to the JVM). The macros, while not hygienic, do have some features to help you avoid variable capture, so you can capture variables if you really want to, while running less risk of accidentally doing so than in CL. You've got easy access to all the Java libraries; that's probably a good thing for "real world" code, and fairly pointless in terms of learning. It's got a set of libraries for persistent data structures and support for STM, which make it very interesting from a concurrent point of view; this makes it probably your best bet if you're interested in learning more about new methods of dealing with concurrent and parallel programming. It appears as if Clojure is as usable for large, production applications as Java, in the sense that it's going to have the ability to do the "ugly stuff" you do in production apps that you'd rather not do and don't do when you're learning.

  4. Emacs Lisp. In terms of a LISP, this is not one of the better examples out there. One of its biggest faults is dynamic scoping, but there are many others. However, if you're an Emacs user, this may be the most powerful tool you can learn to improve your use of the editor. How much you'd really learn from learning Emacs Lisp, beyond how to extend Emacs, is for me an open question however; I don't know how often interesting techniques such as high-order functions are really used in Emacs Lisp.

2018 Update

It's been almost a decade since I wrote this post and the Lisp family of languages now appears to be gaining significant traction in the general programmer consciousness. Much of this appears to be related to Clojure which has not only become a properly separate dialect of Lisp in its own right, introducing many of its own good ideas, but also now has a near-identical version targeting JavaScript and has inspired many other Lisps targeting other platforms. For example, Hy targets the CPython AST and bytecode, aiming first for interoperability with Python, but using Clojure ideas "when in doubt." (Though from the latest commits, the latter may be changing a bit.)

The big change this brings in your decision-making process is that you should also be looking at whatever Lisps or Lisp-like languages are available for and interoperate with languages or platforms you already use, be it Perl, Ruby, Erlang, Go or even C++ on microcontrollers.

cjs
  • 25,752
  • 9
  • 89
  • 101
  • 3
    Having separate namespaces is not a wart, it is just a different design decision. Keep in mind that there are already several other namespaces also in Scheme, so the debate is rather Lisp-5 against Lisp-6. Apart from the convenience that I can call a list "list" and a car "car" in CL, its macro system is just so much more practical and useful, because the compiler doesn't confuse things so easily. – Svante Jun 20 '09 at 03:36
  • Clojure doesn't have tail call optimization, and it can't, because the JVM bytecode doesn't support it. All it has is a "recur" special form that self-recurses the current function. – Svante Jun 20 '09 at 03:39
  • Svante: thanks for your TCO comment; I've added a note to the post that the need to use 'recur' may go away if the JVM adds TCO support. – cjs Jun 20 '09 at 03:45
  • Svante: what other namespaces for variables does Scheme have? – cjs Jun 20 '09 at 03:52
  • 3
    Curt: I'd argue that Clojure is the most portable since it runs on the Java VM. – justinhj Jun 20 '09 at 04:05
  • 1
    I don't know about that; if you exclude small and embedded devices (such as telephones and smart cards) where you're not going to be running an unmodified desktop/server program anyway, elisp certainly runs on many more CPUs and platforms than the JVM. – cjs Jun 20 '09 at 04:19
  • I would think that "emphasizing recursion much less" is an advantage to Common Lisp, not a disadvantage. – Sean McMillan Nov 11 '09 at 20:15
  • 2
    I strongly disagree. Recursion tends to produce code that's a) more pure, b) easier to verify, c) more likely to be correct. In more detail: a) it tends less to touch fewer variables outside of the function; b) an inductive proof tends to naturally drop out of the recursive function, whereas with loops you need to check loop invariants, etc.; c) reliability comes from a) and that you tend to be pushed to code in a way that naturally makes you do (perhaps informally) the inductive proof of b). – cjs Dec 04 '14 at 08:39
  • "R5R2"? also, PLT Scheme is now Racket. – Will Ness Jul 03 '18 at 22:35
  • So being someone that works with Java and the Spring framework, but has enjoyed playing around with Elm. Would you recommend learning Clojure over Scheme? – David Domingo Sep 12 '18 at 14:00
27

I would say Scheme, solely because of the Little Schemer, which is one of the most mind-blowingly fun yet extremely hard books I've ever tried to read.

J. Polfer
  • 12,251
  • 10
  • 54
  • 83
12

I can recommend Common Lisp on SBCL. This combination is fast, powerful, mature and well-documented.

benekastah
  • 5,651
  • 1
  • 35
  • 50
Leslie P. Polzer
  • 2,998
  • 21
  • 18
9

Also Clojure is a gaining a lot of mindshare these days, and for good reason. Great data structures, profoundly good concurrency support (puts Scheme and CL to shame in this regard), and a great community. It's also relatively simple, CL is as at least as complicated as C++.

This isn't to say I don't enjoy CL or Scheme. I learned Scheme with SICP. And CL brought me to Clojure. It all depends on your goals I suppose. If you want to learn a Lisp that is immensely practical go for Clojure. Otherwise CL or Scheme are both great.

dnolen
  • 18,496
  • 4
  • 62
  • 71
  • This seems to imply that neither CL or Scheme are "immensely practical", while they are quite practical in fact. Especially the CL standard was *born* out of practical considerations. – Leslie P. Polzer Jun 18 '09 at 09:04
  • 2
    The programming language landscape has changed since 1994, I don't know how the CL standard is going to change/evolve to accommodate what has been learned since that time. The world is lurching forward and as far as I can tell CL is standing still. I like CL, Clojure has some way to go to approach its power, but I don't see how CL is going to evolve- if you're going to use a standardized languages an evolutionary path must be apparent. Without it, a language is very likely _not_ a practical choice. – dnolen Jun 18 '09 at 21:00
  • 4
    CL has evolved and is evolving through a lot of very useful libraries. The base language was already more powerful in 1994 than all "modern" languages today. – Svante Jun 20 '09 at 03:21
7

I learned Scheme in school. It was a great learning experience and I will never forget the fundamentals of functional programming. It probably doesn't matter which version of LISP you pick up, as long as you understand the core of its usefulness - stateless lambda calculus.

Here's an interesting article on Why MIT switched from Scheme to Python in its introductory programming course.

Svante
  • 50,694
  • 11
  • 78
  • 122
jinsungy
  • 10,717
  • 24
  • 71
  • 79
6

I prefer CL, since I like object-oriented programming, and CLOS is the nicest object system around.

jrockway
  • 42,082
  • 9
  • 61
  • 86
  • 5
    Speaking of CL, I would recommend either ClozureCL or SBCL. Both are open source, well-documented, mature, multi-platform, and provide crucial non-standard functionality like multithreading. – Daniel Dickison Jun 17 '09 at 14:14
3

I would say all of them, at least at first. Eventually you will probably develop a preference for Scheme or Common Lisp, but they both have enough differences that it's best to get a handle on everything that's out there.

Scheme has continuations for example, and it's good to learn about those in Scheme, even though they can be implemented in Common Lisp.

Learning the difference between lexical and dynamic scope is important, and if you learn both Common Lisp and elisp you'll come across the implications of both.

justinhj
  • 11,147
  • 11
  • 58
  • 104
1

LFE (Lisp Flavored Erlang) would be nice. You can have the lisp syntax on top of the Erlang VM.

1

Was a kind of "loaded" question to begin with but OP probably didn't know about it. Generally, Common and Scheme lispers are like PC and Apple computer "people", they don't mix. Which one is best is probably not as relevant as which one "works" for you. Really, there is not that much difference. Likely a preference for one over the other maybe influenced by which one you learn first. (To me, an empty list should be "nothing", known in CL as NIL, and that makes me a Common Lisper.) I like the integration of SBCL with Slime using EMACS, but SBCL is not for everyone. For one thing, SBCL is very strict. If you just want to "have fun" the GNU clisp is easy and available for virtually every platform.

Wiley
  • 506
  • 5
  • 4