Any advantage in LISPs having simpler grammars than Python?

Terry Hancock hancock at anansispaceworks.com
Tue Mar 7 18:59:56 EST 2006


On Tuesday 07 March 2006 04:21 pm, seberino at spawar.navy.mil wrote:
> Is there any advantage to a language having a nice mathematically
> compact grammar like LISP does? (or at least used to?)
> Many have admired the mathematically simple grammar of LISP
> in which much of the language is built up from conses IIRC.
> Python's grammar seems complicated by comparison.
> 
> Is this anything to worry about?

Certainly I'm not going to lose any sleep over it. ;-)

I think the cool thing about Lisp's tiny grammar is that it
proves you can make a grammar that small work. It's
minimalist to the extreme.

The trouble is, while it may be easy for the machine to parse,
it isn't the machine's clerical ability we are worried about!

Ultimately any such determination is aesthetic, so there will
inevitably be disagreement, but for some of us, at least, the
Python syntax is a much better balance between simplicity and
adequate discrimination and visual cues.

Perl, for example, is much further along on that spectrum -- it
has a large number of "punctuation" symbols (symbolic operators,
really). Lots of "visual cues", but it's not simple at all.

The nice thing about symbolic operators is that they are very
compact and very easy to distinguish from one another. The bad
thing about them is that they are not as easy to remember as
words, and they are very difficult to look up, compared to
words. Therefore, you have to "just know" what they mean.

Or rather -- learning them is part of comprehending the core
language, as opposed to something you learn as you go along.

Word symbols, like Python's keywords, standard library functions,
classes, and methods are easier to look up in the manual if you
get stuck.  They also put user constructs on a much more even
footing with things built into the language. So -- I don't have
to write a PEP if I just want a useful feature I can implement
in a module.  Using that approach, I can construct a "domain
specific language" in python or lisp. In a way, that's what all
modules do (at least they allow you to expand the vocabulary of
the language, though most leave the grammar alone).

Lisp gives you that kind of power to the nines.  It lets you
rewrite the vocabulary, grammar, and whatever to get the job
done the way you want.

And then people use it.  And that leaves you, as the end user, to
learn a new language for each application.  And the extremely
limited grammar means that there are few visual cues to sort out
what is part of Lisp, what is part of a library, and what is your
own code.  It's like a paper without hierarchical heading styles.
You can read it, but it's not as easy as one which is structured
with visual cues as to what is a heading, what is a section number,
what is emphasized, etc.

Some people apparently love Lisp, but I really could never get
over the nested parentheses making my eyes cross. ;-)

I think experienced Lisp programmers must learn to visually
parse the *words* in the Lisp program to determine the structure,
but I find that really unhelpful, myself.

Remember that you *can* represent your program with nothing but
two characters, "0" and "1" -- even simpler than Lisp.  That
doesn't mean that that's the "preferred form for editing" it. ;-)

Cheers,
Terry

--
Terry Hancock ( hancock at anansispaceworks.com )
Anansi Spaceworks  http://www.anansispaceworks.com



More information about the Python-list mailing list