3 ms·
Seeing as how one of the arguments for teaching JavaScript first is that it lets you teach about prototypical inheritance before the students get used to class-
by gliese1337 15y ago
Seeing as how one of the arguments for teaching JavaScript first is that it lets you teach about prototypical inheritance before the students get used to class-based inheritance, the complexity of simulating a class in JavaScript is probably not the best objection to using it instead of CoffeeScript. If you teach them CoffeeScript, then you will teach them class-based inheritance just like everywhere else, and miss out on the prototype paradigm.
- latchkey 15y agoI'm ok with missing out on the prototype paradigm. To me, it is a wart for JavaScript. There has been a ton of discussion on why libraries like DateJS, which pollute the Date prototype, are bad. http://stackoverflow.com/questions/4823682/javascript-namespace-pollution-issue http://stackoverflow.com/questions/4823682/javascript-namesp...
- wwweston 15y agoThe discussion you're linking to doesn't appear to discuss either general problems with the prototype paradigm or specific problems with adding properties/methods to the Date prototype. The closest it seems to come is a warning about not trying to modify the prototype of an object through its __proto__ property (or, I suppose, .getPrototypeOf), which isn't the same thing.
- Cushman 15y agoPersonally, I treat the `class` keyword as a useful (and powerful) macro for constructing prototypes. I imagine if someone thought they were building a 'real' class-based program for too long, they'd be in for a few surprises later on.
- jashkenas 15y agoThis is a common misconception. CoffeeScript's "class" keyword is just JavaScript prototypal inheritance. They work and are used in precisely the same way. There's nothing here to "miss".