2 ms·
>I think the three examples seem reasonable when viewed in the right way These kinds of statements is why I think webdev is completely and thoroughly fucked. W
by colllectorof 9y ago
>I think the three examples seem reasonable when viewed in the right way
These kinds of statements is why I think webdev is completely and thoroughly fucked. When obviously bad software or language design is widely accepted on the basis of convoluted technicalities you know that thing will not get better, only worse.
>This type of issue isn't unique to JavaScript. In Java, if you have boxed Integers
Boxed types in Java were a clusterfuck of their own. They shouldn't be used as justification of bad design in other languages. A cautionary tale, more like.
- alangpierce 9y agoI think most people (including me) would agree that type coercion makes JavaScript a worse language, and that boxed types are one of the ugliest things in Java. By "the three examples seem reasonable when viewed in the right way", I mean that it's possible to build an intuition about how JavaScript behaves in these situations, and it doesn't require memorizing a giant spec. The behavior isn't random, it's the consequence of some early design decisions that likely should have been made differently, and understanding those design decisions will make you a better JavaScript programmer. Many smart people have been working on improving JavaScript for a while now, and many of the problems have been fixed either by language improvements or widely-available tools. The runtime behavior of basic operators can't be changed, though, so we'll likely be stuck with the type coercion rules for a long time, although it's worth noting that both TypeScript and Flow disallow `null >= 0`.