3 ms·
There are a lot of problems (not merely "quirks", but outright problems) with JavaScript that have absolutely nothing to do with past or present browser-based i
by PommeDeTerre 14y ago
There are a lot of problems (not merely "quirks", but outright problems) with JavaScript that have absolutely nothing to do with past or present browser-based implementations. They're problems that are inherent to the language itself.
I'm talking about things like its extremely broken equality operators, its extremely broken array handling (especially the behavior of the length property), semicolon insertion, its broken scoping, its lack of support for proper class-based OO, its lack of support for proper namespacing and modularity, its lack of proper typing, and so forth.
These are far worse, and in many cases much stupider, than any problems we see with C, C++, Java, C#, Python, Ruby, Erlang, Perl, Haskell, Scheme and whatever other mainstream or semi-mainstream language you want to choose.
PHP is perhaps the only widely-used language that exhibits the same kind of idiocy when it comes to many core features. But at least it has been moving in the right direction, with its much more sensible support for OO and namespaces, for instance. We keep hearing about how ECMAScript 6 will finally bring at least some sensibility, but this is still very much up in the air.
It's incorrect to say that JavaScript is an "objectively good programming language". It's objectively terrible, and all of the evidence proves this very conclusively.
- AnIrishDuck 14y agoMost of your peeves are addressed by correctness checkers like JSLint, or have been alleviated by community projects. There's a lot of hate here, so I'm going to address your points one by one: > I'm talking about things like its extremely broken equality operators, Don't use language features that are broken. Use === and !== instead. JSLint complains about this. > its extremely broken array handling (especially the behavior of the length property), You're going to have to elaborate here, I have no idea what you're talking about. > semicolon insertion, Put semicolons at the end of each line manually. Or don't use crazy multiline expressions. JSLint will flag this down for you. Other languages like C force you to do this, why the JavaScript hate? > its broken scoping, Never put things in the global scope. Always use var. Global-by-default is annoying, but very easy for static tools like JSLint to flag and nag about. > its lack of support for proper class-based OO, Javascript's objects are very minimal; they can easily emulate semantics of other OO languages. In my code I usually emulate the Python copy-superclass-on-class-creation semantics of subclassing. > its lack of support for proper namespacing and modularity, RequireJS has effectively solved this problem for me. As per above, you should never put things in global scope anyway. > its lack of proper typing, If you're looking for built-in static typing, you came to the wrong place. I think it's important to remember that JavaScript the language was designed to be very minimal (IIRC the entire initial language was created in a week); in that regard, it at the very least is not a good fit for static typing. I personally wish that it had stronger types, and can agree with you here that ideally this would be different. > and so forth. I guess I don't see your concerns here. I prefer writing JavaScript over C and Java; it allows me far more leeway for creating abstractions through closures and anonymous functions. Think of JavaScript's problem statement: create a simple minimal universal browser-based language. It's hard to imagine a better language in JavaScript's place (Scheme is the only realistic alternative I can think of). Here's a nightmare scenario for you: we could have ended up with Visual Basic instead. JavaScript isn't perfect, but what language is?
- KingMob 14y agoWhile I don't quite agree with the parent poster, half of your points involve a) best practices, which require programmer discipline, not parser smarts, b) a lint-checker, which again, is not as good as the parser itself forbidding something, or c) using certain libraries, which is not as portable and easy as direct language support. While I agree that these issues are surmountable, I don't think you've rebutted the point that they are issues with the language itself. That being said, no language is perfect and for being whipped up in a day, Javascript's pretty nice.