merits of Lisp vs Python

Paul Rubin http
Mon Dec 11 10:17:40 EST 2006


Bill Atkins <atkinw at rpi.edu> writes:
> > There's no way you could compile Python to efficient
> > machine code just by macro expansion. You'd also need
> > some very heavy-duty type inferencing.
> 
> When I used to use Ruby a lot, I believed this line that the Ruby
> community fed itself (and apparently Python feeds itself as well):
> Ruby/Python has to be interpreted because it's too dynamic. 

I don't think you can reasonably compile Python just by what we'd
usually call macro expansion.  You need fancier compiler techniques.

> > Python is extremely dynamic, even more so than Lisp.
> > That's why compiling Python is hard, not because it
> > doesn't have macros.
> 
> Uh huh.  "More so than Lisp"?  Just making stuff up now?

Python is more dynamic than Lisp.  

> Despite its dynamism, Lisp is quite compilable.

Yes.  Lisp is dynamic, but less so than Python.  And not by
coincidence, Lisp is more compilable than Python.

> For example, I can redefine classes, functions, macros, etc. at
> runtime and compiled code referring to the old code will still work.
> You are conflating dynamism with interpretedness, and that's
> incorrect.

If you say foo.frob() in Python, that's supposed to look up 'frob' in
a dictionary hanging off of foo.  You can modify the contents of this
dictionary any time you want.  The Lisp equivalent would be some
generic function (frob foo) that you define with CLOS in the usual
way, but then there's some hashtable that lets you redefine frob at
any time by modifying it (i.e. just a normal hashtable that you poke
with setf, no special notification to the class system).  This can
happen anywhere in the code, in another thread, or whatever.  You can
even replace that hashtable with another hashtable.  You can also
insert (at any time) a __getattr__ method into foo's class, that is a
user-supplied function that replaces the hash lookup.  

This stuff is all quite hard to optimize the way CLOS can be
optimized.  I'd like to hope Python tones down these aspects of its
dynamism as it continues to evolve.



More information about the Python-list mailing list