3 ms·
Prototypes vs classes is a matter of taste, and I don't think "power of expression" can be measured.
by pwpwp 17y ago
Prototypes vs classes is a matter of taste, and I don't think "power of expression" can be measured.
- mbrubeck 17y agoI think lsd5you is probably referring to the fact that you can trivially build classes on top of prototypes, while the reverse is not generally true (as far as I know). So a prototype-based language can easily express both classes and other forms of OO.
- lsd5you 17y agoYeah, although the trade off is that as class construction is procedural with prototypes you know longer have a declarative type system. Any type checking will have to come from type inference (when possible).
- btilly 17y agoSorry, but it isn't that hard to build prototypes on top of classes in a dynamic language. The cleverest and shortest implementation I've seen is http://snippets.dzone.com/posts/show/3378 http://snippets.dzone.com/posts/show/3378 where the following snippet of Ruby code does it: Proto = Class.new(Class) # Beware: magic. def Proto.clone Class.new(self) end (Follow the link for an explanation of usage.) However several other languages have implementations. For a random example see http://search.cpan.org/~teverett/Class-Prototyped-1.11/lib/Class/Prototyped.pm http://search.cpan.org/~teverett/Class-Prototyped-1.11/lib/C....