Need arguments for "Python vs. Perl as an OOPL"

Raymond Hettinger vze4rx4y at verizon.net
Tue Sep 23 01:13:11 EDT 2003


"Roy Smith" <roy at panix.com> wrote in message
news:roy-002696.23242122092003 at reader2.panix.com...
> I'm working on a prototype of a new application in Python.  At some
> point, if this ever turns into a product, the powers that be will almost
> certainly demand that it be done in Perl.  My job will be to convince
> them otherwise.
>
> The basic design of the application is object oriented.  I've never used
> Perl's OO features, so I'm not in a good position to make a comparison
> of the two languages from an OO point of view.  Can somebody who's done
> OOP in both Python and Perl help me out?
>
> I certainly know why Perl sucks in general, but for this purpose, I need
> to specifically compare the OO features of the two.  I'm looking for
> something more fundamental than "->{} is ugly".

If you're to find a major difference in OO implementations, it will likely
be with Python's new style classes.  So, the advantages are:

* easy implementation of metaclasses through __metaclass__
* super() for cooperative superclasses
* a method resolution order that supports cooperative superclasses
   and complex inheritance hierarchies
* __slots__ for lightweight instances
* o.__getattribute__ for easy intercepts of method calls and attribute lookup
* descriptors which make easy work of otherwise hard tasks
* the fruits of descriptors:  class methods, static methods, and properties
   (which make it possible to avoid coding many getters and setters).

Other than the new-style gizmos, it's mostly the same candy in a different
wrapper.


Raymond Hettinger






More information about the Python-list mailing list