News for hackers. Stuff that matters.
Re:Local State Is Poison (2012) by kbenson on Friday December 27, 2013 @11:31AM (#6971268)
I've worked on similar code. Global state which is sometimes twiddled directly in the main loop, other times functions are called that take no arguments and return nothing, but they compute something and set global variables.

Not pretty is an understatement. It's ugly at best, and rage inducing most the time.

Re:Local State Is Poison (2012) by dllthomas on Friday December 27, 2013 @01:49PM (#6971997)
It helps when you can use the type system to restrain what can touch what. I've been doing this in some of my high performance C, where some global mutable state is unavoidable - passing around empty structs to indicate context. It doesn't guarantee I don't violate my rules, but it more likely I notice when I do.
Re:Local State Is Poison (2012) by kbenson on Friday December 27, 2013 @02:09PM (#6972089)
It's almost never as bad when you design it yourself. Then the logic and reasons are apparent. Coming into such a system from the outside can be tough though. An explanation of the rationale and pre and post conditions is very helpful, even if all it does is keep a future programmer from trying to circumvent the system and causing the problems it was implemented to avoid.