News for hackers. Stuff that matters.
Re:Blessed Are the JavaScript Developers by mcphage on Monday August 31, 2020 @04:53PM (#24335827)
> What's the intuitive way to handle:

Most of the examples you provide are meaningless. What is the intuitive way of comparing a number and a function? There isn't one, the question itself is meaningless. Saying "hey look we found a way to come up with an answer by turning everything into a string" isn't right either, since it means you come up with the wrong answer in plenty of situations—like in the original tweet.

I'd rather have a library that gives you the correct answer in important common cases, at the expense of not being able to answer questions that don't have an answer. The solution JS went with was to get the important cases wrong, so that it could handle cases that don't have a meaning or use.

Re:Blessed Are the JavaScript Developers by danShumway on Monday August 31, 2020 @05:29PM (#24336153)
> I'd rather have a library that gives you the correct answer in important common cases, at the expense of not being able to answer questions that don't have an answer.

The problem is that optimizing for the common cases and ignoring the difficult or meaningless cases is exactly how you end up with 20 different rules for how something should work that all handle the situation kind of well, but interact with each other to create horrible, crazy bugs whenever anything unexpected happens.

Look, Javascript type conversions are a disaster, I'm not going to pretend otherwise. But the reason they are a disaster is specifically because the language was so worried about making everything intuitive that it didn't stop to think about what would happen when the half-dozen 'helpful' type conversions interacted with each other in novel situations.

It's better to have one or two rules that work everywhere, even if they occasionally surprise a new programmer. Beginners will only be beginners for a small, finite amount of time, but they will need to deal with your language quirks and emergent weirdness for the rest of their lives.

If more of the core Javascript language embraced that philosophy, it would be a better language to program with.

It's the "don't worry about the edge cases, just make the obvious case right" thinking that got us class syntax that doesn't actually build classes, and strings parsed into numbers for `>` but not `+`, and basically the entirety of `==`. Because all of those situations had slightly different answers about what was the "intuitive" thing to do, and nobody thought any farther than the isolated, immediately obvious use-cases for those features.