News for hackers. Stuff that matters.
Re:Preact, a fast 3k React alternative by nilliams on Thursday January 28, 2016 @01:16PM (#10990020)
Well for one 'class Foo extends Bar' will work without any further code to make inheritance work in the way you'd expect, including use of super() etc. Whereas your second example is using non-trivial framework code, that some framework author has to write. See Backbone's extend() for a clear example of what is required [0]. That's work that every framework author is potentially going to implement differently, needlessly.

And the fact that almost every major framework has implemented something similar themselves is proof enough (for me at least) that the ES6 sugar is valuable. It has nothing to do with Java, it's simply a useful pattern that everybody was already using.

[0] http://backbonejs.org/docs/backbone.html#section-247

Re:Preact, a fast 3k React alternative by gisenberg on Thursday January 28, 2016 @11:28PM (#10993498)
A note that using extends Component will cost you the function auto-binding that [p]react.createClass provides. In my specific case, using extends produced code that read more poorly.
Re:Preact, a fast 3k React alternative by jbergens on Friday January 29, 2016 @09:59AM (#10995537)
But it's sad that not more framework authors tried StampIt or similar instead of reimplementing inheritance (more or less badly)

https://github.com/stampit-org/stampit

Re:Preact, a fast 3k React alternative by jallmann on Thursday January 28, 2016 @01:32PM (#10990134)
The question is whether that ~15 lines of code, written once, is worth the substantial increase in the surface area of the language, especially when overlapping so much with the existing prototypal inheritance mechanism. The choice to use Java/C++-style inheritance is a design pattern that doesn't necessarily reflect the only (or even the best) way to accomplish things.
Re:Preact, a fast 3k React alternative by Touche on Thursday January 28, 2016 @02:03PM (#10990384)
ES6 classes do not use Java/C++ style inheritance, they are still the same as writing:

  function Foo() {

  }

  Foo.prototype = Object.create(Parent.prototype);

  ....
It's just sugar, nothing more.
Re:Preact, a fast 3k React alternative by jallmann on Thursday January 28, 2016 @03:37PM (#10991095)
The semantics of JS classes are still different in enough subtle ways: constructors and constructor subclassing, (lack of) object properties, hoisting, etc. That is on top of the new keywords, new function syntax, etc. All that needs to be mapped onto the model of "classical" Javascript in order to completely understand the language. There are enough gotchas there to disqualify JS classes from being simply sugar.
Re:Preact, a fast 3k React alternative by Touche on Thursday January 28, 2016 @03:43PM (#10991149)
You can add object properties to a ES6 class's prototype, no?

EDIT: Just tested in Firefox and indeed you can.

Re:Preact, a fast 3k React alternative by jallmann on Thursday January 28, 2016 @04:10PM (#10991370)
Not in the class declaration, though. Why force the programmer to go through the prototype, when ES6 provides such a "convenient" abstraction around it?
Re:Preact, a fast 3k React alternative by phpnode on Thursday January 28, 2016 @06:05PM (#10992212)
Coming to the spec soonish and already supported in Babel - https://github.com/jeffmo/es-class-fields-and-static-propert...
Re:Preact, a fast 3k React alternative by yelnatz on Thursday January 28, 2016 @02:23PM (#10990516)
Being a C++ developer during the day and a web dev at night, this syntactic sugar is actually a breath of fresh air.
Re:Preact, a fast 3k React alternative by djacobs on Thursday January 28, 2016 @03:55PM (#10991253)
I'm not yet convinced that it's just syntactic sugar. For example, what (generic) code is `super` syntactic sugar for?

Even if it is just syntactic sugar, that syntactic sugar makes it much more approachable for devs who want to use classical inheritance (not that I'd encourage that).

Re:Preact, a fast 3k React alternative by secoif on Thursday January 28, 2016 @06:56PM (#10992505)
> what (generic) code is `super` syntactic sugar for?

  super.propertyOnSuper ~= this.__proto__.propertyOnSuper

  super() in constructor ~= ParentConstructor.call(this)
and some tools provide such things like this.super_:

https://github.com/isaacs/inherits/blob/3af5a10c6b51f9e99d9f...

Re:Preact, a fast 3k React alternative by djacobs on Thursday January 28, 2016 @11:05PM (#10993413)
Thanks for the response. If the choice is between manually specifying that (type of) code for every kind of object (and likely moving to a #create factory method) or using a native syntax for class declaration, I can see why people would choose the latter.
Re:Preact, a fast 3k React alternative by qaq on Thursday January 28, 2016 @01:42PM (#10990201)
It's to a degree for people who are not primarily JS developers and often have no clue about prototypical inheritance. It also to a good degree reflects how V8 or some other engine actually treating your code under the hood.
Re:Preact, a fast 3k React alternative by keithwhor on Thursday January 28, 2016 @01:56PM (#10990323)
The language surface area has already increased. The decision has been made.