4 ms·
great article that clearly articulates js prototypes. I'd have to disagree with ender7 though, I think JS prototypes are not a "poorly-designed system" they're
by jfaucett 14y ago
great article that clearly articulates js prototypes. I'd have to disagree with ender7 though, I think JS prototypes are not a "poorly-designed system" they're just different from classical forms of OOP inheritance. And contrarily, I would recommend anyone to delve deeper into prototypes - an alternative method to class based OOP.
- ufo 14y agoIt still could be much better designed though, compareed to othe rprototipical languages. Prototypes cannot be explicitly accessed or mutated, Object.create wasn't even part of the standard and the whole syntax with function constructors and having to set the prototype property is a very ugly hack.
- jfaucett 14y agoI haven't used any other prototypical languages so I can't say how js compares... Can you give me the best prototypical language? - I'd like to check it out and see for myself. Still, as far as shimming up a clean cross browser API prototyping is extremely usefull.
- natrius 14y agoI don't know much about this, but I've heard Self mentioned as the prototypical prototypical language many times. http://en.wikipedia.org/wiki/Self_(programming_language) http://en.wikipedia.org/wiki/Self_(programming_language)
- tikhonj 14y agoIt's the language where the idea came from originally. It's basically the Smalltalk of prototype-based OO :). Here's a nice paper about it: http://ranger.uta.edu/~nystrom/courses/cse3302-fa10/selfPower.pdf http://ranger.uta.edu/~nystrom/courses/cse3302-fa10/selfPowe...
- walrus 14y agoJavaScript's prototypes really are poorly designed, though. To see how it probably should have been done, check out the programming language Io (http://iolanguage.com/ http://iolanguage.com/) or Douglas Crockford's note on prototypal inheritance in JavaScript at http://javascript.crockford.com/prototypal.html http://javascript.crockford.com/prototypal.html (specifically, the 2008-04-07 update).