HAYCORN — 5 January 2006

About Lisp

I get the im­pres­sion that there exist quite a few people who like the idea of pro­gram­ming in Lisp, but at the same time write ab­solutely no Lisp code, either in or out of work. The code they do write will be in­flu­enced by Lisp ideas and concepts, but they never ac­tu­ally write Lisp itself. (I, you see, am one of these people.) Why is this?

The ar­gu­ment gen­er­ally seems to be that this is due mostly to factors largely outside Lisp’s control: no in­sti­tu­tional support and poor libraries, for example. But I’m not con­vinced this tells the whole story–when you get right down to it, Lisp the lan­guage isn’t all that great. (The Lisp you imagine is much better than the Lisp you ac­tu­ally get.)

Here’s one example: Lisp’s non-intuitive semantics. For all its sup­posed sim­plic­ity and or­thog­o­nal­ity (“everything is a list”, etc.), Lisp does, on occasion, behave in ways that aren’t very programmer-friendly. The stan­dard Common Lisp book, for example, says:

In Common Lisp, unlike some other Lisp dialects, the im­ple­men­ta­tion is per­mit­ted to make “copies” of char­ac­ters and numbers at any time. … The net effect is that Common Lisp makes no guar­an­tee that eq will be true even when both its ar­gu­ments are “the same thing” if that thing is a char­ac­ter or number.

One con­se­quence of this is that:

 ((x 5)) 
 (eq x x)

can some­times be true, and some­times false (!). (But … it’s the same goddamn x!) What’s worse, though, is that in practice, this ex­pres­sion will almost always eval­u­ate to be true–so the problem is some­thing that’s not likely to be dis­cov­ered in testing.

Do good Lisp com­pil­ers warn about this (and suggest eql)? It’s possible, though this is not likely to calm the nerves of the spec-reading programmer. (Holy crap, they think, what other traps await?)

Another problem: Lisp, as written by non-experts, is slow. Modern, com­piled Lisp is sup­pos­edly just as fast as C, etc., and I am pre­pared to believe that it’s possible to get Lisp pro­grams running as fast as pro­grams written in other languages. I don’t, however, believe that this is easy. This is partly ex­pe­ri­ence talking: I did my honours project in Lisp, and tried fairly hard to get it running fast. I was using a sup­pos­edly high-quality Lisp com­piler (Allegro Common Lisp on Irix), and even­tu­ally was using, for example, actual arrays (and not lists)–but it still ran like a dog. Someone, probably, could’ve made it run a whole lot better, but my point is that someone with my level of Lisp knowl­edge should have been able to make it run a whole lot better.