Python, Lisp, and other languages

William D Ricker wdr at TheWorld.com
Thu Dec 8 22:19:01 EST 2005


Python <python at venix.com> wrote 
> As a confirmed python nut, 

The email name was a bit of a warning, but I appreciate the explicit
disclosure.  My own Pythonesque nuttiness is confined to the capitalized
form, as in the BBC series. I'm a Perl Monger, and was an awk addict
before that.  The Camel-Spotting sketch is right up in the canon with
Parrot, Lumberjack, Blackmail, and the Twin Peaks of Mt.  Kilimanjaro.
I sympathize with Guido's choice of naming honoree, if not in syntactic
"sugar".

> I could not resist tossing another URL onto
> the thread.
> http://norvig.com/python-lisp.html
> (Peter Norvig is Google's Director of Research)

Most of his comments apply equally well to Perl, of course.
(Barring the three-way religious issue of punctuation.)

I'll reply with an URL for the book and website that describes how to
do really lisp style stuff in Perl, including stuff that's hard in
Python --
 http://hop.perl.plover.com/

Peter Norvig is honest in the python link above to admit the real failings
of even modern Python in doing what Lisp does well --

<<Now [with Python 2.2] you can create closures over read-only variables. 
  If you do need to modify a variable that you close over in a function,
  you have a few options, all of them a little cumbersome.>>


Readonly closures are fine for "pure functional" write-once
programming, but (outside academe) that's not the real winner Lisp
style.  For implementing truly reusable APIs, closures are essential,
as MJD's Higher Order Perl (HOP above) shows -- including modifiable
closures. 

Besides Lisp, Perl and Ruby may be the only languages with general
purpose read/write closures.  Having to do an extra indirection of
one sort or another in the closure to have write-access to the
contents of its closed variable means Python is technically equivalent
"strength" but loses something important in expressiveness -- the
expressiveness is what Lisp wins on.

<<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,
  [... but ...] This was rather a disappointment to me. 
  [...] It seems that only a real expert would want to manipulate Python
  parse trees, whereas Lisp parse trees are simple for anyone to use. >>

With Filter::Simple, Perl has a facility of distressingly similar
power to Lisp Macros, but without even less grounding in tokenization.
Using Filter::Simple isn't as simple as Lisp macros, but simpler than
accessing the Python Parse tree.   Some marvelous magic has been
created with Perl Filter::Simple.

> I do realize that language debates can last forever since different
> folks place different values on different features while also facing
> different challenges and situations.

Indeed. Another trope is comparing the old original or standard version
of the other language to the latest or enhanced version of their favorite.
(If I compared Perl 6 to Python 2.0, I'd obviously be cheating.)

Cheers,

-- 
/"\     Bill Ricker  N1VUX  wdr at world.std.com
\ /     http://world.std.com/~wdr/           
 X      Member of the ASCII Ribbon Campaign Against HTML Mail
/ \     http://use.perl.org/~n1vux/



More information about the gnhlug-discuss mailing list