6 ms·
> Was it really necessary to add "class" syntactic sugar? Yes. Now your editor/IDE knows that that thing is supposed to be a class. The doc generator also know
by ahoge 12y ago
> Was it really necessary to add "class" syntactic sugar?
Yes. Now your editor/IDE knows that that thing is supposed to be a class. The doc generator also knows that it's a class. Furthermore, this makes things more compatible since framework A and library B use the same kind of classes.
Finally, it means that you won't have to waste time with evaluating a dozen semi-popular options to handle classes/inheritance.
It does of course also make your code a lot easier to read and it makes it easier for new developers who used some other language with classes before.
> Hopefully ES7 doesn't get the verbose syntax of Java/C#.
I recommend to take a look at TypeScript and Dart. Optional types aren't verbose. You just add some types to the surface area, which, compared to JSDoc, is drastically less verbose. Inside functions, you can generally omit the types.
- castell 12y agoOptional types are great. I think he meant static types like in Java / older C#
- frik 12y agoIt's a pity that optional types are still missing in ES6. As I wrote: A good example is Facebook's Hack language that improve PHP in a sensible way and adds optional typing - something that would be great for ES6/7. In comparision the Java/C# type is static at compile time. Newer C# version have like e.g. Visual Basic 6 a variant type that is a tradeoff (as wasteful as a "union struct" in C). The class syntax in ES6 is just syntactic sugar. JS IDEs like WebStorm/PHPStorm/IDEA already can parse "classes" with JS5 syntax . But what about the arrow syntax: var odds = evens.map(v => v + 1); Or the iterator syntax that ES6 got from TypeScript: interface Iterable { [Symbol.iterator](): Iterator }