Python was designed (was Re: Multi-threading in Python vs Java)

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Oct 19 05:57:14 EDT 2013


On Wed, 16 Oct 2013 23:49:02 -0700, Peter Cacioppi wrote:

> I don't know if I want to step into the flames here, 

Go on, be bold! You learn a lot by making bold claims and having them 
shot down. Or at least, I did. Now I know everything, so I can afford to 
be humble.

*wink*


> but my
> understanding has always been that in the absence of polymorphism the
> best you can do is "object based" programming instead of "object
> oriented" programming.

Well, that surely depends on the semantics of what you mean by "object 
based" versus "object oriented", and I don't think there is any one hard, 
universally agreed upon definition of those.


> Object based programming is a powerful step forward. The insight that by
> associating data structures and methods together you can significantly
> improve readability and robustness.

This implies that "object-based" simply means that you have *syntax* for 
associating methods with data, i.e. objects. I don't think I would agree 
with that definition. For instance, I often describe Python as "object-
based" in the sense that *all* values in Python are objects, even things 
which would be low-level primitives in some other languages, although you 
can still write procedural, imperative or functional-style code.


> Object oriented programming takes things further, most significantly by
> introducing the idea that the object reference you are referencing might
> be a run time dependent sub-class. 

And I *strongly* disagree with this. I wonder whether you have read this?

http://en.wikipedia.org/wiki/Object-oriented_programming#Fundamental_features_and_concepts

Quote:

    Benjamin C. Pierce and some other researchers view any attempt
    to distill OOP to a minimal set of features as futile. He 
    nonetheless identifies fundamental features that support the
    OOP programming style in most object-oriented languages: 
    [list of five feature]

    Similarly, in his 2003 book, Concepts in programming languages,
    John C. Mitchell identifies four main features: [...] Michael
    Lee Scott in Programming Language Pragmatics considers only
    [three features]


It is notable that polymorphism is *not* one of the three features listed 
by Scott (although it is included by the other two). So I don't agree 
that subtype polymorphism is necessary for OOP.

I can easily conceive of object-oriented languages with inheritance but
no subtype polymorphism. For instance, prototype-based OOP languages have
inheritance, but since they don't really have types in the class-based 
OOP sense, they don't have subtypes, hence no subtype polymorphism.



> Even Python, which isn't strongly typed, 

That's not the case, although that's been discussed in other posts.

> manages polymorphism by allowing the self argument to a sub-class
> of the method class.

I must admit I don't really understand what this sentence is supposed to 
mean.


> There are many wonderful examples of object based programming in C. I
> believe VB (not VB.net, the older VBA language) is object based but not
> object oriented.
> 
> True object oriented programming 

http://en.wikipedia.org/wiki/True_Scotsman_fallacy


> seems to require proper support from
> the language itself, because the run-time resolution of the "this/self"
> reference needs specific constructs in the language.

Again, I don't understand what you are trying to say here. Provided that 
the "this/self" reference has a type, what more does the language need to 
provide? The reference itself is enough to identify the instance (since 
it is the instance!) and the instance's type is enough to identify the 
type (since it is the type!).


> Bear in mind that my usual disclaimer when wading into the flames like
> this is to quote Randy Newman ... "I may be wrong .... but I don't think
> so!!"

:-)


-- 
Steven



More information about the Python-list mailing list