HAYCORN — 5 January 2006

About Lisp

I get the impression that there exist quite a few people who like the idea of programming in Lisp, but at the same time write absolutely no Lisp code, either in or out of work. The code they do write will be influenced by Lisp ideas and concepts, but they never actually write Lisp itself. (I, you see, am one of these people.) Why is this?

The argument generally seems to be that this is due mostly to factors largely outside Lisp’s control: no institutional support and poor libraries, for example. But I’m not convinced this tells the whole story–when you get right down to it, Lisp the language isn’t all that great. (The Lisp you imagine is much better than the Lisp you actually get.)

Here’s one example: Lisp’s non-intuitive semantics. For all its supposed simplicity and orthogonality (“everything is a list”, etc.), Lisp does, on occasion, behave in ways that aren’t very programmer-friendly. The standard Common Lisp book, for example, says:

In Common Lisp, unlike some other Lisp dialects, the implementation is permitted to make “copies” of characters and numbers at any time. … The net effect is that Common Lisp makes no guarantee that eq will be true even when both its arguments are “the same thing” if that thing is a character or number.

One consequence of this is that:

(let 
  ((x 5)) 
  (eq x x)
)

can sometimes be true, and sometimes false (!). (But … it’s the same goddamn x!) What’s worse, though, is that in practice, this expression will almost always evaluate to be true–so the problem is something that’s not likely to be discovered in testing.

Do good Lisp compilers 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, compiled Lisp is supposedly just as fast as C, etc., and I am prepared to believe that it’s possible to get Lisp programs running as fast as programs written in other languages. I don’t, however, believe that this is easy. This is partly experience talking: I did my honours project in Lisp, and tried fairly hard to get it running fast. I was using a supposedly high-quality Lisp compiler (Allegro Common Lisp on Irix), and eventually 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 knowledge should have been able to make it run a whole lot better.