News for hackers. Stuff that matters.
Re:Cognitive loads in programming by q845712 on Wednesday August 31, 2022 @11:27PM (#32671573)
hey seriously, i've been grappling with this: what better candidate to be a global variable than a shared cache that otherwise has to be passed through dozens of function calls (which imo adds cognitive load at many places through the stack).
Re:Cognitive loads in programming by drakmaniso on Thursday September 01, 2022 @02:19AM (#32672670)
I don't think passing state through functions calls add cognitive load: it just make it visible. Global state has the same cognitive load, except hidden.

If a state is passed through dozens of function calls, this may indicate that it is shared by too many parts of the code, or that it is managed at the wrong layer of the architecture. When using global state, these potential problems are difficult to spot.

Re:Cognitive loads in programming by arinlen on Thursday September 01, 2022 @02:50AM (#32672903)
> (...) which imo adds cognitive load (...)

Choosing to ignore input data does not reduce cognitive load. You are not supposed to ignore the core function of your work, and call it a good practice.