Javascript is getting too fat

How to mess up a beautiful language

Published: 2012-04-01

Anger

I really did not want to write this post at all because I prefer writing in a positive spirit. However the Javascript community makes me angry as hell. They just managed to kill a beautiful language called Javascript.

The Javascript Gem

In essence Javascript is a beautiful language. If you only use literals, you have a very minimalist programming language that is even capable of supporting well designed object oriented designs without the concept of classes. This is impressive. If you don't know what I mean, read my post 'minimalist approach to OOP in Javascript'.

The dark side

Javascript always had a dark side; it's riddled with confusing constructs like prototype. The new-keyword is another confusing element in the language. It does not even belong in a classless language. And then there is the this keyword, which is quite problematic.

Main problem

The main issue with Javascript is that there are too many ways to do OOP: using literals, object augmentation, prototypes, functional inheritance and more.... Because of this every library has a different style, thus making interoperability quite challenging. Worse, prototypical OOP even makes it possible to alter native objects.

Madness

Instead of cleaning up, the Javascript community has decided to add even MORE ways to do OOP. New OOP techniques like Object.create are being introduced. But that's not all, soon you can also build objects using Object.defineProperty, hell you can even freeze objects or seal them and I don't even WANT to know what that means. The proposed fat arrow functions even have a different way of handling the this-concept, thus breaking yet even more compatibility. On top of this mess there are techniques that aren't standardized like those using the __proto__ object from Mozilla.

Conclusion

I used to be a real fan of Javascript, but in my opinion the language is turning into a nightmare; ugly features are popping up everywhere and there seems to be nobody out there with a sense of elegance. In about ten years from now Javascript code bases will be regarded as the most unmaintainable ones and this will mark the demise of my beloved language. There is one glimpse of hope though: Dart. I hope that the Google engineers will keep Dart clean and small. My advice to the Dart team: keep it simple.



back to homepage