3 ms·
I don't think the particular examples are pitfalls that people actually fall into, but I do think they illustrate what makes Javascript hard: it's got a lot of
by tel 12y ago
I don't think the particular examples are pitfalls that people actually fall into, but I do think they illustrate what makes Javascript hard: it's got a lot of arbitrariness.
Arbitrariness is a constant mental penalty a programmer must pay for while reasoning in a language. It is not insurmountable, but one must wonder what could happen if the arbitrariness tax were reduced or lifted. It could be that whole realms of greater, more trustworthy abstraction are obscured by mental barriers such as this.
- bshimmin 12y agoI think the seemingly arbitrary behaviour of things like `[] + []` vs. `[] + {}` doesn't really affect you, as someone writing real JavaScript in the wild, very often (but perhaps they still might do occasionally, depending on what you're doing). On the other hand, errors in logic because of truthiness/falsiness do occur pretty regularly in real code (I'm sure every JavaScript developer has at least once forgotten to check whether an argument is really undefined and then not very gracefully handled `0` being passed to that function)... and these problems do all have the same root cause: JavaScript's type system.