Why don't people like lisp?
Andrew Dalke
adalke at mindspring.com
Thu Oct 23 02:13:00 EDT 2003
Paul Rubin:
> Actually in my experience that hasn't been a problem. For example, I
> wrote a program that crunched EDI documents.
Ahh, you're right. I tend to omit business-specific languages
when I think about programming.
I conjecture it would have be about the same amount of work to
do it in Python, based solely on your description, but I defer to
you on it.
> superficially looked like an unholy marriage of Basic and Cobol.
heh-heh :)
> > > Do people write any significant amount of code in the Python parse
> > > tree syntax?
>
> Peter Norvig talks about this some in his Python/Lisp comparison page:
>
> http://www.norvig.com/python-lisp.html
>
> Basically the Python AST structure is awful, but you arrange your life
> so you don't have to deal with it very much.
His description starts
] Python does not have macros. Python does have access to the
] abstract syntax tree of programs, but this is not for the faint of
] heart. On the plus side, the modules are easy to understand,
] and with five minutes and five lines of code I was able to get this:
] >>> parse("2 + 2")
] ['eval_input', ['testlist', ['test', ['and_test', ['not_test',
['comparison',
] ['expr', ['xor_expr', ['and_expr', ['shift_expr', ['arith_expr', ['term',
] ['factor', ['power', ['atom', [2, '2']]]]], [14, '+'], ['term',
['factor',
] ['power', ['atom', [2, '2']]]]]]]]]]]]]]], [4, ''], [0, '']]
I completely agree. Manipulating Python AST and the parse tree
are not for the faint of heart. However, he's not working with
the AST
>>> import compiler
>>> compiler.parse("2+2")
Module(None, Stmt([Discard(Add((Const(2), Const(2))))]))
>>>
The code I wrote uses the AST and, while clunky, isn't as bad
as his example suggests.
> There's one area where Lisp absolutely rules, which is providing a way
> to write down complicated data structures without much fuss. These
> days, XML is used as a Bizarro cousin of Lisp S-expressions in all
> kinds of applications for similar purposes.
That's an old debate. Here's a counter-response
http://www.prescod.net/xml/sexprs.html
Andrew
dalke at dalkescientific.com
More information about the Python-list
mailing list