On Jun 13, 2006, at 3:10 PM, Shane Hathaway wrote:

Michael L Torrie wrote:
Well given that "modern" languages are really just a return to the
theories worked out in the 60s (LISP really has everything that modern
languages have and more)

I guess you threw in that flamebait for fun. :-)

But I'm not looking for flamebait.  In all honesty, I'd like to know
more about the "and more" part of your LISP statement.  What am I
missing by not using LISP?  I don't mean some random feature like
pretty-printing numbers.  What deep philosophy is in LISP that other
languages have yet to discover?

Lisp (no one calls it LISP anymore; the capitalization was an artifact of old terminals, not of an acronym or anything that would suggest that it should continue to be in all caps) has been pretty well mined through the years, and almost all of its features have, individually, been incorporated into other languages. However, it does have some properties that continue to differentiate it from mainstream languages.

1. S-expressions: These are the nested parentheses that so many people love to hate. An s-expression is basically a structured way to write data. This is not unusual in itself; the interesting part comes from the fact that code is formatted within s-expressions rather than in a more conventional syntax. This was initially meant to be only an internal representation of programs, but due to historical accident and the unexpected power that programming in s- expressions brought, lisp programmers never really adopted a more complex external representation for their programs.

What do s-expressions buy you? Easy code transformation. Because a lisp program is essentially a textual representation of its abstract syntax tree, it is very simple to programmatically analyze and transform the program. This brings us to...

2. Macros: Lisp macros are very different from the preprocessor macros in languages like C and C++. The C preprocessor works on text without knowledge of the C language itself, so it is fairly easy to write macros that result in syntax errors. The C preprocessor language is also very different from the C language, and far more limited.

Lisp macros, on the other hand, are implemented in lisp and work on s- expressions that have already been read and parsed into lisp lists and trees. A macro receives as its arguments data that represent the abstract syntax trees of the code it is meant to expand. The full lisp language is then available to perform those transformations at compile time.

The macro facility is one of the primary reasons that lisp is so flexible and has adopted so many different programming paradigms. Macros have been used to create object systems, aspect oriented programming systems, advanced flow control mechanisms, and all sorts of other experimental stuff, some of which was later added to the language itself.

3. Image-based development: This one is not unique, as Smalltalk does it even better. What this means, though, is that running Lisp systems are very dynamic, and updates/recompilation can be done without stopping the running programs. The compiler and the read- eval-print loop are built into the runtime system, and any aspect of the runtime system can be updated on-the-fly. This is wonderful for two different kinds of things, exploratory programming and patching high-availability systems with no downtime.


Of course, there are downsides to all of these, and reasons why they aren't more common. Lisp is worth learning for many reasons, but one of them is so you can learn these ideas and understand when they are worthwhile and when they are not. Personally, I find lisp a lot of fun to program in, and I've learned a lot about programming from it. It's not the best language at everything, but it is a pretty good general-purpose language, and probably the most flexible computer language in existence. It's not *easy* but it's fairly straightforward, and with enough study and effort, it molds itself into exactly what you want. It's a great hacker's language.

                --Levi

/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/

Reply via email to