Prototype OO

Bruno Desthuilliers bruno.42.desthuilliers at wtf.websiteburo.oops.com
Thu Mar 20 07:33:45 EDT 2008


sam a écrit :
> 
> Some time ago (2004) there were talks about prototype-based languages 
> and Prothon emerged.
> 
> Can someone tell me why class-based OO is better that Prototype based, 

For which definition of "better" ?-)

> especially in scripting langage with dynamic types as Python is?
> 
> 
> Here are some links:
> 
> http://c2.com/cgi/wiki?PrototypeBasedProgramming

Most of the arguments in favor of prototypes seems to come to, mainly:
1/ it lets you customize behaviour on a per-object base
2/ it removes the mental overhead of inheritance, classes etc

Point 1. is a non-problem in Python, since you can already add/replace 
methods on a per-objec basis (ok, with a couple restrictions wrt/ 
__magic__ methods and such).

Point 2. is not (IMHO) such a problem in Python, where inheritance is 
mainly an implementation detail (it's not needed for polymorphic 
dispatch to work) and class hierarchy tend to be very flat, when they 
even exist.

Mainly, Python's object system is actually quite close to javascript 
here. That is, you get more or less the same flexibility. And a couple 
of powerful features you don't have with javascript (like hooks in the 
attribute lookup mechanism), too.








More information about the Python-list mailing list