Why is there a JavaScript hate?

There are several key reasons why some developers hate JavaScript. JavaScript hate is actual because

  • JavaScript is really easy to use. Even an normal person can use it. C++, Java, and other languages have a higher barrier to entry. And with junior developers writing a lot of JavaScript, a lot of JavaScript is going to be crap. This is not a a fault of the language, but a side effect of ease-of-use.
  • JavaScript has faults. Other answers go into great detail about them, exaggerating many of them to the extreme, so I won’t bother with them here. It was designed quickly for marketing reasons (so they could say “we have a script language in the browser!”). The thing is, if you use ES2015 and a linter with strict rules, none of those faults are still relevant.
  • Like PHP, JavaScript is a language “good” developers love to hate. It’s a signal that you’re part of the “cool” group, a dog whistle. So people rag on it to show how awesome they are. (I, ahem, may know about this particular fact, because I may have been one of those developers, once upon a time…)
  • JavaScript used to suck a lot more. It’s gotten much better now with ECMAScript 2015 and more recent changes. You can transpile even ECMAScript 2016+ features into ES5, so you can use all the cool features today. But once upon a time, when many of the developers (including myself) first encountered JavaScript, there was a lot to complain about.
  • Problems with the DOM get blamed on JavaScript. JavaScript is a programming language. The DOM and browser functions related to the DOM are simply a JavaScript API. JavaScript compatibility between browsers has been excellent for quite a long time. But everyone remembers the DOM API incompatibilities they had to fight with, and they paint JavaScript with the same brush.

I would say that every one of the major complaints that are found in other answers to this question has been addressed by ECMAScript 2015 and/or modern linters. That includes:

  • Module systems
  • A single standard class system
  • The “value of this”
  • Block scoping (I always have my linter enforce “no var keyword”)
  • Equality (always use ===)
  • Language standardization across implementations
  • Language “quirks” like semicolons (Just. F’ing. Use. Them. And make your linter enforce them! Bang, no problem!) and parseInt sometimes treating a leading zero as if it’s octal (when using “strict mode” parseInt won’t do that any more).
  • And when you’re ready for static types, it has TypeScript as a fully ECMAScript 2015-compatible JavaScript-with-types, after which you’ll never suffer another surprise type conversion that doesn’t work the way you expect.

Which is why I’m using JavaScript (actually, TypeScript) in my day job a lot these days and am not regretting it at all. There’s a lot to be said for it; it’s powerful like a Lisp, but much more readable, and includes a super-powered ecosystem of frameworks and libraries.

Finding similar topics, you should check: technology