IsPython really O-O?

Daniel Dittmar daniel.dittmar at sap.com
Mon Nov 12 05:59:07 EST 2001


Perhaps one should list the differences between Smalltalk and Python. This
would make it easier to decide which of these differences are really
important.

This list is based on Digitalk SmallTalk of 7 years ago, so it might be
dated.

- no strict data encapsulation in Python: true, but I would rate this in the
same area as static type checks

- Classes are objects in Python, but there are used in a different way,
especially when constructing objects. In Python, the runtime creates a new
object and calls the appropriate __init__ method (this is similar to Java).
In Smalltalk, you call a class method. If this method somehow manages to
call 'Object new', then a new object gets created. This approach makes it
somewhat easier to create multiple constructor methods. <Asbestos>I didn't
say it is impossible to have multiple object creation routines in
Python.</Asbestos>

- no multiple return values in Smalltalk (still true?). One could argue that
having a separate class for all such cases is more object oriented. One
could also argue that such nonessential helper classes are simply fluff.

- no code blocks in Python: Python allows to pass callables around, but
lambdas are simply too limited for most purposes. Handling collections in
Python has more of a functional heritage (applying filter to a UserList will
return a list, not a UserList). With all the elements available in Python
2.2 (nested scopes, inheritance from C-classes), it is probably possible to
implement something similar to the Smalltalk collection hierarchy.

- calling conventions are very different (has really nothing to do with
O-O). The Smalltalk syntax does not allow for default arguments (yes, you
can fake them with additional methods) or passing of dictionaries through
keyword arguments. On the other hand, I still believe a listing of Smalltalk
methods gives me a better idea of the functionality than the equivalent in
Python (compare 'from:for:' or 'from:to:' with 'substring')

- adding of code at runtime: Smalltalk allows this, but at least commercial
implementions will remove this from the freely redistributable runtime.

- With Carlton University nearby, anything other than Smalltalk will be a
tough sell.

Daniel






More information about the Python-list mailing list