Re:Server-Side Javascript: Back With a Vengeance
by pwpwp on Friday December 18, 2009 @09:27AM
(#1003131)
Prototypes vs classes is a matter of taste, and I don't think "power of expression" can be measured.
[ Parent
| on HN ]
Re:Server-Side Javascript: Back With a Vengeance
by mbrubeck on Friday December 18, 2009 @10:30AM
(#1003228)
I 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.
Re:Server-Side Javascript: Back With a Vengeance
by btilly on Friday December 18, 2009 @05:06PM
(#1004098)
Sorry, 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 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/C....
Re:Server-Side Javascript: Back With a Vengeance
by lsd5you on Friday December 18, 2009 @11:25AM
(#1003364)
Yeah, 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).