While I appreciate these insights and concerns, I’ve been torn on this issue. Should we avoid ES6 classes since more powerful and flexible alternatives exist? After a lot of debating, I’ve decided to use ES6 classes in some contexts, albeit carefully.
Fewer Decisions = Win
Even Sub-Standard Standards Have Value
If you show a team of object-oriented devs ES6 classes, they’re less likely to slap everything in one file.
Low Learning Curve
If you’re working on a team that already understands classes, then ES6 classes are clearly easier to understand than the alternatives mentioned above. They look, feel, and operate similar to the C# and Java classes so many enterprise developers have already embraced (yes, for better or worse).
If we want to be successful with mindsets like this, it sure helps to choose an easy, consistent, and familiar approach.
It’s Just Sugar
Sure, classes are merely syntactic sugar. They don’t enable any new capabilities. And yes, classes also mask the power of prototypal inheritance. But this sugar does make it easy to encapsulate logic. Classes make it simple to declare static functions via a single keyword. There’s no need to learn a pattern. Which is good, because as I alluded to above, only your most dedicated client-side developers will bother learning alternative approaches like stampit or patterns like higher order functions.
Examples are increasingly written in ES6 using classes. Seeing familiar looking code when you Google is a major feature. It speeds reading and increases comprehension. Sure, we are free to use alternative approaches, but we do so at the risk of confusing fellow developers who are looking for code that matches the demos.
Here’s a few other notable benefits by Axel Rauschmayer
They are a standard for single inheritance. There are way too many inheritance libraries and we are already seeing some of them being replaced with ES6 classes (in Ext JS, in AngularJS 2, soon in Ember.js, to some degree in React).
Related to the previous item: they help tools (such as IDEs and type checkers) analyze source code statically.
You can subclass built-in constructors such as Error.
They are compatible with current code that uses constructors.
A Bright, Standardized Future
Cory House is the author of “Building Applications with React and Flux”, “Clean Code: Writing Code for Humans” and other courses on Pluralsight. He is a Software Architect at VinSolutions and trains software developers internationally on software practices like front-end development and clean coding. Cory is a Microsoft MVP, Telerik Developer Expert, and founder of outlierdeveloper.com.