Prototype OO

Diez B. Roggisch deets at nospam.web.de
Fri Mar 21 13:48:04 CET 2008


> I can see that Python and Javascript inheritance model is almost the 
> same. Both languages are dynamically typed. And it seems that using 
> "classes" in Python makes some things more complicated then it is 
> necessary (eg functions, methods and lambdas are differen beeing in 
> Python concept).

Sorry, but that is utter nonsense. It begins with the fact that there is 
no "inheritance model" in Javascript. Or why does each JS-lib provide 
it's own version of an extend-function [1]? Which one has to grasp 
before really being able to use inheritance in JS. And of course 
everybody does it a bit different, including possible access to parent 
classes and such. Calling that an advantage is rather bold.


And it continues with the abnomination the implicit "this" in Javascript 
is - e.g. MochiKit offers a bindThis-method to ensure that a method-call 
always gets the actual instance passed as this - something that can get 
"lost" when dealing with event-handling. Whereas python here offers the 
bound-method-concept.

The only point you might have is the somwhat unfortunate distinction 
between lambda and function in python - but this is on a syntactical 
level only. Once created, you can use them as you like.

I do like JS for what it is - but everybody who uses it in an OO-manner 
ends up inventing the same wheels Python already comes with.

Diez

[1] Just one example: http://docs.mootools.net/Class/Class.js



More information about the Python-list mailing list