4 ms·
I upvoted you for talking about historical accident, but regretted it when you started in on Javascript and Objective-C. Yes they have some questionable decisio
by krichman 14y ago
I upvoted you for talking about historical accident, but regretted it when you started in on Javascript and Objective-C. Yes they have some questionable decisions but they are by no means objectively awful.
- rayiner 14y agoGiven that Javascript was designed in 1994, not 1974, I think it rises past "questionable design decision" not to just use Scheme's lexical scoping rules (i.e. the only sensible lexical scoping rules). Although to be fair, scripting language designers keep getting this wrong for some reason.
- krichman 14y agoYeah that's a problem. I thought you could get proper scoping by writing "var" in front of everything?
- mercurial 14y agoThat's function scope, not block scope. You can use the "let" keyword to get block scope since Javascript 1.7.
- PommeDeTerre 14y agoIt still took over a decade to get what should have been available from the very beginning. That's a pretty serious problem that repeats time and time again with JavaScript.
- deleted 14y ago[deleted]
- mercurial 14y agoOh, definitely. But I haven't found it overly problematic in practice. I'll point out that Python, a language much more appreciated than Javascript on HN, has no scope smaller than function scope. Which is mostly fine as long as you stick to small functions, which you should anyway.
- mercurial 14y agoFrankly, 'var' is fine most of the time. Keep writing small functions and all that. Besides, you have 'let' now. I have much a bigger beef with the type system (or lack thereof), the array-and-hashes-as-one-datatype stupidity and the lack of a module system.