Print

Print


And Rosta writes:

> Being a syntactician and not a programmer, I wonder why programmers
> don't use trees. An interface like the one used for Windows directory
> structure (where you click on nodes to expand and contract them) seems
> ideal. Surely programmers can't be guilty of a kind of cerebrally
> masochistic machismo?

Lisp code *is* a literal tree (parentheses demarcate subtrees); a Lisp
program is a huge tree of expressions. All programming languages end up
being represented internally, in an intermediate stage, in their parsers
and/or virtual machines as trees; but it turns out to be a really bad (=
difficult and slow) way for humans to write code. Instead, most
programming languages end up allowing the user to write a series of
smaller trees ("statements" made up of "expressions").

There's one extreme, where every language construct is a machine
instruction, and the machine simply executes each instruction in order.
That's a flat representation. The other extreme is Lisp, where there is
one huge tree and only the most trivial program is a flat list of
instructions. Languages that people actually want to use fall somewhere
in between.

It turns out that cerebral masochism looks a lot like Lisp (and its
bastard offspring, XML). Also, given that real-world computers are
machines that execute flat lists of instructions, the "impedance
mismatch" between how Lisp structures code and how the machine works
results in Lisp code being orders of magnitude slower than code written
in a language that more closely reflects the way the machine works.

Lisp people: please flame me off-list, if you have to flame me. ;)


--
http://chris.nodewarrior.org/