DEV Community

Discussion on: Is JavaScript the most confusing programming language?

Collapse
 
curtisfenner profile image
Curtis Fenner • Edited

As I mention, all of these behaviors have fairly concise explanations. However, having to know dozens of bizarre edge-cases that do come up in real code reduces the space you have in your head for thinking about the important problems in front of you (and instead you have to spend time thinking about language trivia).

These complexities are not inherent to implicit type coercion, dynamic typing, closures, etc. Lua has all of these things, and none of the gotchas that JavaScript has.

For example, in Lua, tables are simply mappings from objects to keys. == is the same thing as what determines if two keys map to the same value (so, e.g., {[{}] = true} actually does do what it says it does; 1 == "1" is false, t[1] isn't the same thing as t["1"]; but you can write 1 + "1" == 2 yet 1 .. "1" == "11").

The fact is, that many of JavaScript's complexities/gotchas/points of confusion are unnecessary. The fact that they can be overcome is secondary to the fact that you have to overcome them: if JavaScript were designed slightly differently, you would not have to worry about them (and this can in most cases be done without sacrificing any linguistic power and convenience)