A Comparison Between Scheme and Common Lisp
Posted by Peter on March 11, 2006
Before putting down my ideas on why I prefer Scheme over Common Lisp I did a brief internet search on the subject, but there was very little comparison between the two. I did find plenty of comparisons to other languages, but as I am not going to beat a dead horse by telling you why I think Lisp is great there is no need to go into what I have found.
And before you get a false impression I would like to stress that I think both Scheme and Common Lisp are excellent languages. Also I am comparing Common Lisp to PLT Scheme specifically. Now with that out of the way lets get into the details
Advantages of Common Lisp:
More features: If you have read my blog you will notice that I am often implementing in Scheme features found in standard Common Lisp, such as defun and destructuring-bind. Although it is fun and educational it shouldn’t really be necessary.
Macros: Macro definitions in Common Lisp are much simpler and intuitive than those you write in Scheme. Since macros are one of the key features that make Lisp such a powerful language this is a big advantage over Scheme. The problem with Scheme macros is that the clean and simple syntax for macro definitions only handles basic transformations. As soon as you need to do something complicated, for example inspection of any of the macro’s parameters, life is no longer clean or simple. In Common Lisp however the most complicated aspect of macros is avoiding unwanted variable capture, and to be honest with a little practice using gensym it isn’t that hard.
Documentation: I can’t say enough good things about the books and online documentation for Common Lisp. Scheme on the other hand is, in my experience, poorly documented. To be honest Scheme’s documentation for new users is excellent. However complicated or advanced features are poorly documented. The PLT language manual, while useful, is a notorious offender in terms of being difficult to understand and leaving things out.
Libraries, user base: Common Lisp is obviously ahead here.
Advantages of Scheme:
Simpler: Wait didn’t I say that more features was better? Well there is a downside to having many features, it makes programs that exploit those rarely used corners of the language that much harder to understand.
Functions are really first class: Although Common Lisp is a functional language it makes programming functionally much harder than Scheme. For example to call a function that was returned as a result you have to use the funcall expression. Likewise special operations are required to access the function value of a variable. This seems unnecessary to me.
Continuations: Scheme has them, Common Lisp doesn’t, end of story. Continuations are extremely powerful and useful. I sometimes compare continuations to macros, because like macros you don’t know how powerful they are until you start using them.
Editor: My one failing in life may be that I am not an emacs fan. Personally I find emacs unnecessarily complex. So this point is really a matter of personal preference, but Dr. Scheme, my editor/environment of choice is a pleasure to program in. It also makes introducing people to Scheme that much easier.
You already know what I am going to say here, I like Scheme better. My two selling points were basically the editor, which made it easy to get going right away with Scheme and continuations. I haven’t blogged yet about continuations, but rest assured that I will, as they may be almost as important as macros.
Update: I have found one comparison here, and this one seems to come to the conclusion that Common Lisp is generally better. Bah!