3 ms·
This doesn't do a good job of supporting its thesis. The new syntax does in fact allow most devs who understand "traditional" class based inheritance to use JS
by hashkb 9y ago
This doesn't do a good job of supporting its thesis. The new syntax does in fact allow most devs who understand "traditional" class based inheritance to use JS the way they expect. The fact that it's implemented in JS is both good and also OK to ignore for most devs.
- hajile 9y agoIn my experience, the class syntax has been more bad than good. Devs with experience in other languages simply start writing classical OOP code without realizing the ramifications of what they are doing. Unless you are creating thousands of rigidly structured instances (never adding/removing properties or changing property types), you are almost always going to be better off using the factory pattern instead where you get other benefits like no `new` and real privacy.
- untog 9y ago> the ramifications of what they are doing Which are? And why is "no new" a benefit? IMO it's a good thing that you can write JS in the way you write other languages. It makes it a lot easier for developers to get going with it.
- tonyedgecombe 9y agoI'm trying to learn modern JavaScript at the moment, as well as getting to grips with prototypes I now have additional class syntax to learn and understand. I've gone from learning one way of doing things to two, how is that easier to get going with?
- always_good 9y agoBecause now there's one way instead of everyone bringing their own createClass/inherits implementation. Also, prototypical classes like `function User` are now rare in my experience going forward.
- smokeyj 9y ago> Because now there's one way instead of everyone bringing their own In theory. In reality there's everyone bringing their own plus one more. I think the appeal of JS is that it's a universal runtime, not anything about the language itself. I really wish syntactic changes would be left to transpilation.. because that's what every JS developer is doing anyways.
- always_good 9y agoI don't find there to be a difference. Javascript has new features. That you have to compile at all is because of legacy targets. That browsers are adopting these new features just means that you'll need to eventually polyfill fewer of those features and reduce bundle size. But it's still Javascript that's changing. So I'm not sure what you mean by "left to transpilation" which seems to indicate that you're suggesting that something like Babel would have its own Babelscript. But most changes in Javascript I think are just about unanimous improvements like Promises and async/await and const/let and for/of and destructuring. We just like to circlejerk over class vs prototypes as if most people actually care. We can't help it because it's our sport. I regularly see posts on HN where someone is clearly bemoaning Javascript-as-they-used-it-five-or-more-years-ago which muddies the water when trying to have these discussions on HN. Like the anachronisms of people complaining about callback hell.