an oop question

Alan Gauld learn2program at gmail.com
Thu Nov 3 20:09:59 EDT 2022


On 03/11/2022 18:29, Chris Angelico wrote:
> On Fri, 4 Nov 2022 at 05:21, Julieta Shem <jshem at yaxenu.org> wrote:
>>
>> Chris Angelico <rosuav at gmail.com> writes:
>>
>>> On Thu, 3 Nov 2022 at 21:44, Alan Gauld <learn2program at gmail.com> wrote:
>>>> Also Python is not a purely OOP language, in that you can write
>>>> functional and procedural code in Python if you wish. In
>>>> Smalltalk thats notionally impossible because everything
>>>> is an object. And all programming statements are messages
>>>> to objects.
>>>
>>> In Python, everything is an object. Doesn't that equally mean that
>>> Python is purely OOP?
>>
>> I think Alan Gauld pointed out that even syntax is an object in
>> Smalltalk --- or was.  An if-statement in Python is not an object.
> 
> Okay, fair; although I would be highly surprised if syntax is actually
> an object 

The syntax isn't, it is a specification, but the AST certainly
is and you can instantiate it and examine it from code.

But the context here was Why *Alan Kay* doesn't include Python
with Smalltalk as being OOP. There are plenty others who would
call it so.

But as for everything being an object, that's true but it doesn't
alter the fact that the default mode of python programming is not
to structure the code as a set of communicating objects (even if
at some level everything is an object) but as a set of
hierarchical functions.

And fundamentally that's what Kay means by OOP. The program (not
the language!) is built around objects. One of the greatest
barriers to the adoption of OOP is the confusion between OOP
and OOPL. And sadly the majority of attention has been on OOPL
rather than OOP...

> the concept "pass this message to this object" an object? Is the
> message itself an object? Is it objects all the way down?

At some point you hit C/Assembler. But it is astonishing just
how far down the objects go in Smalltalk.

But the control flow etc are fully OOP as per my last message.
It if quite possible to subclass Boolean and override the
whileTrue method to do something completely different to
the normal while loop behaviour. Is it wise? No. But it
is definitely possible!

> At some point, any language with objects in it is "object oriented" to
> some extent, and after that, it's all a spectrum. 

And this is exactly the problem. In the 80s we had a fairly clean
concensus of what OOP meant and several different language approaches
to that. But when C++ became popular(the defacto standard) peple started
focussing on the language features and totally missed that Object
Oriented Programming means writing programs that consist of objects
communicating by messages. The language features(even classes) are
merely implementation details. (I suspect this was partly driven
by the fact that many university lecturers at the time didn't
really grok OOP and teaching language features was much easier
than teaching a new way of thinking about problems!)

This was compounded when someone (Booch maybe?) came up with a set
of criteria to determine whether a language was a "true OOPL" or
merely "Object Based" (Ada and VB they're looking at you!) But
frankly that was an irrelevance to OOP. You can do OOP (and I
have!) in assembler and in COBOL - you just need to follow
some agreed ground rules. It's a lot easier with an OOPL but
it's not required.

> multidimensional thing that's so tangled up that it guarantees that
> people can happily debate for years to come.
Exactly so. During the 90's there came to be at least 3 different
camps of OOP evangelists and the OOP world slowly coalesced on
a kind of hybrid amalgam with multiple names for the same feature
and disagrements about which features are required or not to
really be OOP. And as a result the whole concept of OOP has
been muddied to the point that almost nobody does it anymore
apart from (possibly) the Smalltalk crowd who have always
smugly sat above the general throng content in the knowledge
that theirs is the one true OOP! :-)

Which brings us back to Alan Kay...


-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos




More information about the Python-list mailing list