Python dynamic attribute creation

Bruno Desthuilliers bruno.42.desthuilliers at websiteburo.invalid
Mon Jun 28 05:43:22 EDT 2010


Carl Banks a écrit :
> On Jun 27, 3:49 am, Bruno Desthuilliers
> <bdesth.quelquech... at free.quelquepart.fr> wrote:
>> WANG Cong a écrit :
>>
>>> On 06/26/10 00:11, Neil Hodgson <nyamatongwe+thun... at gmail.com> wrote:
>>>> WANG Cong:
>>>>> 4) Also, this will _somewhat_ violate the OOP princples, in OOP,
>>>>> this is and should be implemented by inherence.
>>>>    Most object oriented programming languages starting with Smalltalk
>>>> have allowed adding attributes (addInstVarName) to classes at runtime.
>>> Thanks, I have to admit that I know nothing about Smalltalk.
>> Then you really don't know much about OO.
> 
> I don't really know much about Smalltalk either.
> 

Duh. I cancelled this totally stupid and useless post a couple seconds 
after hitting the send button, but still too late :(

So first let me present my apologies to WANG Cong and everyone else, 
this was a crude, arrogant and totally stupid thing to say, and I should 
know better. Sorry.

Now on why I first wrote this (warning : personal opinions ahead):

"object" started with Simula, but objects in Simula are mostly glorified 
ADTs with type-based "polymorphic" dispatch. Smalltalk (and all it's 
environment) got _way_ further  by turning this into a coherent whole by 
introducing messages (which are more than just type-based polymorphic 
dispatch - Smalltalk's messages are objects themselves) and "code 
blocks" - as the only mean to control "flow". I believe that Smalltalk 
is (so far) the only "OO" language that was innovative enough to really 
escape from good old procedural programming, and as such possibly the 
only "True" OOPL.

Now for various reasons (including implementation issues and 
conservatism), it happened that the Simula approach to OO became the 
mainstream with languages like C++ then Java, and that most of "OO" 
litterature - "OOP principles", golden rules etc - is about this somehow 
very restricted approach, so people being taught "OO" that way have a 
very restricted - and incomplete - vision of what OO is really about. 
That was how I was taught OO, and I always felt that there was something 
wrong, inconsistant or missing.

Studying Smalltalk (however briefly) was for me a real "AHA", 
mind-opening moment - suddenly OO made sense as this coherent, 
comprehensive and innovative approach to programming I so far failed to 
find in Java or C++.

Now I don't mean one has to master Smalltalk to be allowed to talk about 
OO, nor that OO can't exist outside Smalltak (Python being IMHO another 
exemple of an interesting and mostly coherent object system, even if 
doesn't go as far as Smalltalk do), but - pardon me if this seems 
arrogant (and please correct me if it really is) - I can't help thinking 
that one cannot really understand OO whithout at least a brief study of 
Smalltalk (and - once again - a full Smalltalk environment, as Smalltalk 
the language is only one part of the 'full' object system).

Hope this will at least help those I may have offended understand my 
point, however stupidly I expressed it :(

B.



More information about the Python-list mailing list