Hacker News new | ask | show | jobs
by ScottBurson 3676 days ago
Even something as blatantly broken as the pre-ES6 scoping rules in JavaScript isn't the fundamental problem it's made out to be. It hasn't been stopping people from making great things with the language.

No, it hasn't been stopping them, but I guarantee you it's been slowing them down, at least a little. If nothing else, it makes the language a little bit harder to learn than it needed to be. I'll wager it also causes actual bugs that people have to spend time tracking down. It's true that those bugs can be avoided by proper discipline, but the brain cells required for enforcing that discipline could have been used for something else.

ETA: I agree with the author that a certain pragmatism is useful in selecting a language for a particular project, but I still think it's important to raise people's consciousness about warts in language designs. Doing so improves the odds that the next language someone designs to scratch their personal itch, but that happens to catch on for some reason, will have fewer such warts.

2 comments

Over 90% of the first 100k LOC I wrote was ES5 JavaScript or CoffeeScript. I don't actually recall even a single instance when I was bitten by a bug related to lexical scope on the job. Maybe the problem is people expecting JavaScript to work like Java or some other block scoped language.

Async bugs, on the other hand, were nightmarish at times.

Did you write the same 100 klocs of code in a language with lexical scoping before coming to js?
Another 100 klocs of code before my first 100 klocs of code? That wouldn't have been possible...
Has it been slowing them down as much as debugging new frameworks and build pipelines?

Is it harder to learn a smaller thing with some tricks than a larger thing with few tricks?

Those are two questions I often ask myself when thinking about the evolution of the JS ecosystem.