News for hackers. Stuff that matters.
Re:JavaScript is Dead. Long Live JavaScript by bgrohman on Sunday June 26, 2011 @11:49AM (#2698239)
Yeah, javascript's prototypal inheritance is flexible enough to simulate classical inheritance. I wouldn't call that a wart.

http://www.prototypejs.org/learn/class-inheritance

http://dojotoolkit.org/reference-guide/dojo/declare.html

Plus, I tend to prefer prototypal inheritance to classical inheritance. I do agree that the constructor pattern using the new keyword and the prototype object is a bit odd, but that's not the only way to have objects inherit from other objects in javascript.

Re:JavaScript is Dead. Long Live JavaScript by true_religion on Sunday June 26, 2011 @03:22PM (#2698820)
I've used both methods of inheritance.

Prototypical inheritance in the IO Language is a beautiful thing.

Not so much in Javascript.

Class based inheritance in Smalltalk and its dynamic mind-children Python and Ruby are similarly elegant and flexible. Not so much in C++ or Java.

The problem isn't with Prototypical inheritance, its with the implementation of it in Javascript.

Re:JavaScript is Dead. Long Live JavaScript by WayneDB on Sunday June 26, 2011 @01:11PM (#2698439)
The wart is that since classical inheritance isn't built into the language, we get:

1) Crummy syntax. 2) Everybody doing it a different way.

Re:JavaScript is Dead. Long Live JavaScript by bgrohman on Sunday June 26, 2011 @02:28PM (#2698666)
I see your point to some extent. I don't think the functions for mimicking classes provided by libraries like Prototype and Dojo have particularly crummy syntax. But since there isn't a standardized way to create classes, implementations are usually a little different.

Still, according to this logic, any language that doesn't support classical inheritance has warts. I'm not sure I agree with that. JavaScript doesn't have classical inheritance built in, but I haven't seen anything to make me think that it's really needed from a programming standpoint. Your point #2 is valid, but could that can be attributed to the programmers who use the language rather than the language itself?