Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Given 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.


Frankly, '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.


Yeah that's a problem. I thought you could get proper scoping by writing "var" in front of everything?


That's function scope, not block scope. You can use the "let" keyword to get block scope since Javascript 1.7.


It 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.


Oh, 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.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: