On Sat, Jan 23, 2016 at 08:30:48PM +1100, Cameron Simpson wrote:

> That is the pure OO way; 

Is this the room for an argument? I'd like the full half hour please.

http://www.montypython.net/scripts/argument.php


Without wishing to single out Cameron specifically, I'd like to take 
exception to the way folks are tossing around the term "pure OO". I 
don't think that's a term that adds much light to the discussion, and I 
think it risks being understood as "real OO", a term which is downright 
harmful.

At the very least, people ought to define their terms. What on earth is 
"pure OO"?

If I were to guess, I would think of pure OO in one of two ways:

(1) All values in the language are objects.

That describes Python: everything in Python, modules, ints, strings, 
functions, even classes themselves, are objects. That makes Python as 
"pure" an object-oriented language as it is possible to get.

In comparison, Java fails miserably: unlike Python, but default Java 
treats numbers, strings, booleans as native "unboxed" values, not 
objects.

This is the definition of "pure OO" language given by Wikipedia:

https://en.wikipedia.org/wiki/Object-oriented_programming#OOP_languages


(2) Alternatively, "pure OO" might mean a language which uses only OO 
syntax: alist.len() not len(alist).

Obviously Python is not pure in that sense, but then (i) I don't know 
any language which is, most languages allow non-OO syntax at least for 
arithmetic; and (ii) syntax is the most superficial and unimportant part 
of Object Oriented Programming. 


(3) Others (but not I) might fall for the "No True Scotsman" fallacy and 
use "pure OO" to mean "proper OO", for whatever definition of "proper" 
they like. Unfortunately, or perhaps fortunately, OO covers a lot of 
ground, and very little is mandatory. Just as true Scotsmen do sometimes 
wear trousers, and eat porridge with honey and milk, so almost any 
feature of OOP is optional:

(a) Classes are optional; prototype-based languages like Javascript 
and Lua are no less OO than class-based languages.

(b) Subtyping and inheritence are optional. Some people like to 
reserve the term "object-based" for languages with objects but no 
inheritence. Others distinguish between languages with nominal 
subtyping, like C++ and Swift, and structural subtyping, like Ocaml and 
Go. (Python arguably has both, as duck-typing is a form of 
structural subtyping.)

I could go on, but suffice to say that I will strongly object (pun 
intended) to any suggestion that Python is not a "proper" or even "pure" 
OO language because it lacks certain features some other OOP languages 
provide.

For example, it's popular in certain circles to say that No True OO 
Language lacks information-hiding (sometimes wrongly called 
encapsulation). Since Python has no "private" keyword, Python cannot be 
a proper OOP language like Java, or so they say.

But Java's private variables are not that private:

http://tutorials.jenkov.com/java-reflection/private-fields-and-methods.html

and Python's cooperative information hiding ("just ignore anything 
starting with a single underscore, since that's private") is actually no 
less private than Java's.




-- 
Steve
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to