5 ms·
> First though, why is JavaScript hard? Consider the following cases I've never come across this problem in a real life project, and this is a pointlessly cont
by colinramsay 12y ago
> First though, why is JavaScript hard? Consider the following cases
I've never come across this problem in a real life project, and this is a pointlessly contrived example that diminishes the rest of the article. This is not hard. It might be slightly baffling at the beginning, then after ten minutes you get used to it.
- tel 12y agoI 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.
- pjmlp 12y agoTry to edit JavaScript code in offshored projects with 30+ developers.
- jessaustin 12y agoIs there any language that makes that straightforward? I trust that this scenario is common, but it seems almost comically designed for failure. Why not have someone in the same timezone as the stakeholders break the project up into smaller, more easily offshored modules?
- pjmlp 12y agoAny language with static typing helps a lot, specially since unit tests tend to be non-existent. You can seldom do any validation given the ratio developer/on-site devs.