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

You get functions that are easily testable in isolation with all state provided in parameters.

You also get explicit dependencies and scoping controlled by caller.

I don't mind globals but saying you get nothing for avoiding them is :/



I tend to use getter and setter functions to access globals and manage state.

Advantage only the function that depends on the global needs to bring in the dependency.


If that’s so useful, make your language support the concept of lexical environments instead. Otherwise it’s just manual sunsetting every day of week. Our craft is full of this “let’s pretend we’re in a lisp with good syntax” where half of it is missing, but fine, we’ll simulate it by hand. Dirt and sticks engineering.

(To be clear, I’m just tangentially ranting about the state of things in general, might as well post this under somewhere else.)


So, making it implicit again? No.


You can have it either way, it’s not for you but for people who disagree with what they deem a preference that is the only option when there’s no alternative.




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

Search: