Skip to content

A curated list of resources on why ES6 (aka ES2015) classes are NOT awesome

Notifications You must be signed in to change notification settings

petsel/not-awesome-es6-classes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 

Repository files navigation

Not Awesome: ES6 Classes

A curated list of resources on why ES6 (aka ES2015) classes are NOT awesome

Reverse-inspired by all of the awesome lists on GitHub, like Awesome, Awesome Awesomeness, Awesome JavaScript, Awesome React, Awesome Go, Awesome Elm, etc.

Table of Contents

Introduction

While ES6 brings several useful and syntactically pleasing new features to JavaScript, there are many people in the JS community who feel that adding class syntax to the language was a mistake. I share this sentiment, but I have encountered quite a few programmers in the wild who don't agree or simply don't seem to understand why some of us have this opinion. So, I wanted to create an online reference where people could come to learn specifically about this issue and why they might not actually need class syntax in JavaScript.

TLDR

  • JavaScript is a class-free, object-oriented, & functional programming language. It eschews classical inheritance in favor of prototypal inheritance.
  • Many believe prototypal inheritance to be more flexible and freeing than classical inheritance due to its less rigid nature.
  • The ES6 class syntax, constructors, the new keyword, etc. are ideas taken from the classical inheritance model to make programmers coming from languages like C++, Java, C#, etc. more comfortable and do not really belong in JavaScript.
  • While prototypal inheritance is very powerful in its own right, there is a growing movement among developers, both within and outside of the JS community (Ex: Composition in Golang), to shift away from inheritance in favor of object composition.
  • ES6 class syntax is essentially syntactic sugar that will end up obfuscating the true nature of JavaScript and confusing the next generation of programmers learning it.
  • Instead of ES6 classes, you should consider factory functions, object composition, and/or prototypal inheritance via the use of prototypes, object literals, Object.create(), Object.assign(), etc. while avoiding constructors and the new keyword altogether.

“If a feature is sometimes dangerous, and there is a better option, then always use the better option.”

--Douglas Crockford

Reading

Videos

Contribution Guidelines

Please, ensure your pull request adheres to the following guidelines:

  • Search previous suggestions before making a new one, as yours may be a duplicate.
  • Make an individual pull request for each suggestion.
  • Titles should be capitalized.
  • Use the following format: [Content Title](content link)
  • Choose corresponding section (Reading, Videos, etc.) for your suggestion.
  • New categories or improvements to the existing categorization are welcome. I would like to add a Tutorials/Examples section at some point. Feel free to get started on that if you have the time.
  • The pull request and commit should have clear and useful titles.
  • Each section's list, after your addition, should be sorted alphabetically.

License

Creative Commons License

This work is licensed under a Creative Commons Attribution 4.0 International License.

About

A curated list of resources on why ES6 (aka ES2015) classes are NOT awesome

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published