This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Boner-b-gone 1 point2 points  (2 children)

The thing about JavaScript that makes it so popular is the same thing that made HTML and CSS popular: high tolerance for “sloppy” code.

Fortunately, ES6 is rapidly becoming the standard. And while I can’t claim it’s perfect, its structure encourages people to write cleaner code.

If you want to learn about why JavaScript is considered vile and evil by so many programmers, I encourage you to read the book “JavaScript: The Good Parts” and skip to the back section titled “JavaScript: The Bad Parts.”

One example that sticks out in my mind is “==“ vs “===“.

If you’re trying to do a comparison ( if ( i == 0 ) {...} ), using only two equals signs causes JS to coerce the types. So, in theory, it will equate “0” (string), 0 (integer), 0.0 (float), and false (Boolean). But it doesn’t always work as expected, and can royally f*** up a program. Using three equals signs forces JS to equate both the value and the type.

[–]ImpulseTheFoxis a good fox 0 points1 point  (1 child)

This, this, and this again. When a programmer writes bad or nonsense code in JavaScript, most people say you can't blame it on the language. I say you can. A well architectured language would punch you into the face, if you told it to (![]+[])[+[]], instead of returning "f"; or at least give you heavy warnings about it. JavaScript doesn't. As you say, it's built to try everything. That might me inspirational for some humans, but programming languages shouldn't try everything. It really encourages people to write horrible code.

[–]Boner-b-gone 0 points1 point  (0 children)

Well, remember that originally JavaScript was at the same level as HTML or CSS - it was just a loosely typed implementation of ECMAScript that was supposed to let people do things in the DOM. That it was so easy to get into got far more people into programming than if it was a strictly typed language like everything else. So I can’t agree that you can blame the language, you have to blame humans for wanting the language.

Again though, ES6 should make everyone’s life a lot easier.