3 ms·
I think you are conflating static typing with class-based OO. Python for example is class-based but still fully dynamic. You can mutate classes at runtime, and
by olavk 15y ago
I think you are conflating static typing with class-based OO. Python for example is class-based but still fully dynamic. You can mutate classes at runtime, and even replace the class of an instance at runtime, OTOH Python cannot do the slot lookup optimization you speak of, due to its dynamical nature. Python shows that class-based inheritance is very useful (and easy to use) in a dynamic language.
- SeanLuke 15y agoI believe you may have picked the one language which inadvertently illustrates my point. My understanding is that Python does these things because it's in the SAME bag as JavaScript: it's actually a proto language in implementation down deep, but with a class-based syntax, thus inheriting the disadvantages of both and the advantages of neither. There's some dynamicism bubbling up from the object implementation but it's a far cry from the elegance of a real proto language. I do not know why Guido chose to do this awful thing, but he is at least to be excused given the age of the language. JavaScript has no such excuse.
- olavk 15y agoI guess you could argue that Python is a prototype language deep down because it performs property lookups at runtime by following a chain of objects. (Those objects just happen to be classes.) But by that definition, other dynamic OO languages like Perl or Ruby is also prototype languages. If you think of classes in Python as a feature build on top of prototypal inheritance, then it has certainly proved a very useful feature.
- DmitrySoshnikov 15y agoExactly, Python is a "prototype-based" language with first-class classes as sugar; similar to Coffee. I gave a link below where kinds of classes are described.
- SeanLuke 15y agoMy understanding is that, unlike Python and JavaScript, Ruby has a true class-based OO system. Can't speak to Perl.
- olavk 15y agoThat is interesting, I don't know Ruby that well. But by what definition is Python not a "true" class based OO-system?