... until the collector arrives ...

This "blog" is really just a scratchpad of mine. There is not much of general interest here. Most of the content is scribbled down "live" as I discover things I want to remember. I rarely go back to correct mistakes in older entries. You have been warned :)

1998-12-30

Thoughts on LISP

Lisp is probably the closest thing to my ideal language, of those that I have actually used.  Note that I said 'closest thing to' and not 'is'.  Of course, the concept of 'ideal language' is flawed, because it immediately begs the question of what it is that you are trying to do in the first place.  But, I feel most comfortable programming in Lisp and my productivity is the highest in that language.

It is hard to pick my favourite feature of Lisp.  It might be one of:

  • The compiler is extensible.  I can easily develop my own language tailored to the problem at hand -- so long as that language looks Lispy!
  • The interactive programming environment allows one to build complex applications incrementally.  It is common to leave the application under development running for a whole programming session.  Changes can be incrementally applied to the running application.
  • The list and symbol data types are nice, syntactically lightweight, data structure for lots of purposes that one might use strings for in other languages -- but much more convenient.

But, alas, these features come at a cost.  Here are some things that I do not like about Lisp:

  • The run-time overheads are large.  A 'Hello, World' program might have a 2 megabyte footprint and a 10 to 20 second start-up time.  I suppose I should ignore such trivial issues as memory and disk usage these days, but old habits die hard.
  • The development and run-time environments are hopelessly entangled.  It is difficult to completely jettison the development scaffolding from the final shipping product.  This comes back to the 'overhead' issue.  Apple tried to fix this one in Dylan.
  • The Common Lisp standard says that all declarations (except SPECIAL) can be ignored by a given Lisp implementation.  Most implementations ignore my favourite declarations -- the 'strong typing' ones.

My journey with Lisp began in earnest when I attended a class in University, namely Computer Science 312:  Theoretical Computer Science.  The whole course was taught using Lisp.  I was a little bewildered by the material in the course, but something about Lisp caught my eye.  Later, I was casting about for a project to undertake with my new Lisa computer.  I decided to implement a Lisp interpreter.   Well, actually I acquired a Lisp interpreter written in Pascal from the Internet.   Regrettably, I cannot recall whose it was.  I played with that interpreter for a while, but I found it lacking in some areas that interested me, so I tweaked it a bit and sent my changes back to the author -- who was pleased to see that someone was using his work.  My next try was David Betz' XLISP.  This was written in C, a language I did not know at the time.  I translated the interpreter into Pascal, which went remarkably smoothly.  In fact, most of the translation could be done using global search-and-replace in an editor.  Finally, using what I had learnt in these two Lisp implementations, I was ready to dive into one of my own.  The result was Minilisp, which bears a close family resemblence to XLISP.

Professionally, my employer's main product needed an embedded interpreter for scripting.  My first attempt was an assembly language-like interpreter, which we quickly outgrew.  I then built a simple procedural compiler for that assembly language.  Again, it was just too difficult to write any scripts of note.  The product was written in FORTRAN, so I didn't really relish writing a Lisp interpreter -- even though that was the 'right' answer.  In end, I decided that the effort would be worth it and, after much study of John Allen's excellent Anatomy of Lisp, I produced a SterneLisp.  We were quite satisfied with the capability  that this scripting language gave us, so the successor product was designed with a Lisp scripting language in mind.  The last interpreter that I wrote was SMALL, written in C.  I had grand plans for a follow-on interpreter and compiler (to C), but by then quality Lisp implementations became available on the platforms that my company used, and the need diminished.   Ironically, our experience with Lisp for scripting was so positive, that a commercial Lisp compiler was used as the primary development language for all of the company's products ever since.  That is, until Java came along...

Blog Archive