I would however, strong suggest that javascript shouldn't be someone's only language.
I would however, strong suggest that javascript shouldn't be someone's only language.
Also, js is a lot more inconsistent than python. The amount of js gotchas is huge(== weirdness, hasOwnProperty for iterating through object fields, binding of this, only 64 bit doubles as a number type). Python is much less surprising, and gives you much less opportunities to screw up.
The other things are also not scoping. I’m not arguing JS is consistent, I’m just saying people should stop complaining about its scoping then offering python as a solution.
Honestly, all languages have quirks. When pummeling a language for gotchas, may he whose favourite language is without quirks cast the first stone.
If the quirks reside mostly in parts of the language only touched in really advanced expert use, it's generally not a problem because the people who venture there will know what to look out for. If your language has a quirky while statement on the other hand, it's something everyone will trip over.
E.g. Python's default mutable argument thing is fairly common to trip over (but on the other hand the behaviour is consistent and predictable once you know it), but monkey-patching builtins is not quite as common and definitely in the realm of "don't touch unless you know what you're doing".
`nonlocal` is crazy. That lambdas may only be a single line is annoying. Being unable to print anything out of a map or filter operation without first converting to a list gets tedious quick. And not being able to go in for a quick monkey patch on repr, because builtin classes are magically different than user defined classes in “some way”, which makes modifying them prohibited, is limiting.
Sure, the easy retort is: that’s not what you should be doing anyways, python just enforces it. But I’d personally hate to see such an argument in the comment section of SICP, the pinnacle of programmer freedom.
Edit: and what about mutable default parameters?? I’ve had a fair amount of experience with python and sill been bitten by a mutable default parameter bug (not quite that, but related) in the past couple months. JS gets rid of that entirely by making them just syntactic sugar for what it would do anyways, which is much easier to reason about.
Edit: or was it that I initialized them at time of declaration rather than in the constructor? Not sure. Something along those lines.