Finally discovered kind of explaining something that baffled me


It really pisses me off as I've taken block scope for granted as a default thing.

I've got an open question to people in the community who know more than me, do most modern languages , scripting or not have block scope?

  • 0
    Those answers sorta sound like "technical debt" is the reason. Does typescript introduce block scope? Maybe that is the answer.
  • 1
    Wait until you discover ES6 “classes”
  • 0
    Typescript compiles to one of n JavaScript targets, so it doesn't really add or remove anything. Hence why JavaScript is first class type script.
  • 0
    You can generally expect this from languages that lean class-oriented OOP. They also routinely feature function scope which become indistinguishable from block scopes due to the the class-orientation.

    JS is an oddball since it's technically dynamic and prototypical, that has been band-aided together over 25 years. Because of this it features block, function, module and lexical scoping.

    The various types and levels of scoping are worth a read, especially if you ever do FP:
  • 0
    Python doesn't have block scope either, and it sucks there too.

    Just seems crazy to me, though the "10 days was not enough time to implement it" explanation is definitely sound.
Add Comment