3 ms·
I think that you're misinterpreting disgust as "struggle" when it comes to those people with a more traditional OO background dealing with JavaScript's prototyp
by PommeDeTerre 14y ago
I think that you're misinterpreting disgust as "struggle" when it comes to those people with a more traditional OO background dealing with JavaScript's prototype-based OO approach.
Languages like C++, Java, C#, Objective-C and Smalltalk have very well-defined and consistent ways of declaring classes, inheritance relationships, instantiating objects, using objects, and so forth. With some experience, it becomes extremely trivial to quickly understand and work with such code, even when it was written by other developers far away or long ago.
JavaScript is the opposite. Like so much of the rest of the language, its prototype-based approach is an absolute mess, and this further encourages code that uses this functionality to be a mess, too.
To see what I mean, look at the examples at:
https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Closures#Performance_considerations https://developer.mozilla.org/en-US/docs/JavaScript/Guide/Cl...
Those are three different ways of doing the same thing (and one of them also has non-obvious resource consumption impacts). Those are a very basic case, as well, without even any inheritance. This lack of consistency may not seem like a big deal when it comes to simple examples like that, but it does quickly become an issue in any code written by more than one or two developers, and meant to be maintained for years. Some will claim that coding standards will help here, but they do absolutely no good once integrating code developed independently of said coding standards.
The numerous problems with JavaScript's approach might be excusable if it brought any benefit relative to more traditional OO approaches, but it just doesn't. It takes something that is done quite sensibly in so many other languages, and ruins it. While somebody who started with JavaScript as his or her first (and often only) language may not see these problems, it is very frustrating and disgusting for those coming to JavaScript after years or decades of experience with other languages.
- greggman 14y agoI disagree with your assessment. Arguably your trying to cram non JavaScript style into JavaScript and then getting upset that it'a not what your used to. I had a bad opinion of JavaScript at first too coming from a C++ background. Then I finally stopped trying to make it C++. I never want to go back. Things that are hard in statc languages are so easy in JavaScript. My best advice would be to maybe read though one of the more popular libraries though I don't know which one to recommend. There's a level of elagance there I rarely see in C++