ArticlesEngineering

Stop

JavaScript is getting too big with bad features.

JavaScript is a unique language in that you can do whatever you want, mostly. There is no forced object-oriented and functional requirement. My favorite languages are Elm and Clojure, so I write in a functional style. Developers have a wide range of syntactic ways to represent what they seek to accomplish. This is great if you know what you are doing. But we don’t. JavaScript is headed backwards as we continue to add and misuse more features.

Programming does not have to be hard. You get data, you pass it to functions, you return new data. You read I/O, you write I/O. That covers everything that we actually need to do.

In short, the following are complete trash:

  • Object.defineProperty, Object.getPropertyDescriptor, etc.
  • Getters and setters
  • Classes and Prototypes
  • Iterators
  • Generators
  • Weak Map and Weak Set
  • Symbols
  • Proxies

You will run out of feet before you run out of bullets using these.

Object.* stuff

The methods on Object that are okay: assign, keys, values, and entries. Everything else is stupidly complicated and unnecessary.

Getters and setters

Pretend that getters and setters do not exist in JavaScript for a moment. I have an object o and I access o.foo. We know the complexity of this operation. We know it is going to return the value associated with the key “foo”. We know we have not triggered an asynchronous task. With getters and setters these guarantees go away.

Classes and Prototypes

Coupling data and methods together is not a good idea.

Iterators

All we wanted was a for..of loop for looping through array values. We got an API that suffers from the same problems that getters do: unpredictable complexity, poorly conveyed semantics, and even more in this crazy language to learn.

Generators

Luckily these are not popular anymore because of async/await. Generators only served to be iterator factories and make asynchronous operations look synchronous.

Weak Map and Weak Set

Storing temporary data about data not along side that original data? What could go wrong.

Symbols

Tagging data in ways that only one god system can interpret? What could go wrong.

Proxies

Fuck the whole language? What could go wrong.