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.
You will run out of feet before you run out of bullets using these.
The methods on Object that are okay: assign, keys, values, and entries. Everything else is stupidly complicated and unnecessary.
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.
Coupling data and methods together is not a good idea.
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.
Luckily these are not popular anymore because of async/await. Generators only served to be iterator factories and make asynchronous operations look synchronous.
Storing temporary data about data not along side that original data? What could go wrong.
Tagging data in ways that only one god system can interpret? What could go wrong.
Fuck the whole language? What could go wrong.