3 ms·
I don't understand why everyone considers classes controversial. If you look at code in the wild, it already does what classes desugar to: everyone already writ
by spion 11y ago
I don't understand why everyone considers classes controversial. If you look at code in the wild, it already does what classes desugar to: everyone already writes constructor function and attaches properties to their prototypes.
At least now with classes, users coming from other languages wont be as tempted to make their own completely incompatible object systems.
- dmak 11y agoWhile my example isn't an issue in ES6, most of the controversial came from CoffeeScript. Using classes comes with classical inheritance expectations. In CoffeeScript, changing class variables would carry through all instances, and that is unexpected from a classical inheritance point of view. However, it made complete sense in the compiled JS.
- jestar_jokin 11y agoMaybe I'm misunderstanding, but isn't that the same as static properties on classes in Java?
- hokkos 11y agoIt is more the "extends" than "class" that is controversial because it eschews other pattern like mixins.
- neoeldex 11y agoIn es6 it's finally possible to properly subclass internal types, it properly separates Class properties and prototypes, and it allows users to extend arbitrary classes.