Wednesday, March 23, 2016

"Meanwhile, doing the "right" thing with a global value is significantly harder. It has to be collected, and passed around with varying degrees of difficulty, and could potentially involve hundreds of lines of code if for instance you need to change the type of what is passed around, which is evidence that this is not a simple problem. Nobody "wants" to use a global variable, but if you make it even slightly more convenient than the local "right answer", whatever that may be for a language, programmers are going to use them. Even Haskellers can succumb to the lure of unsafePerformIO $ newIORef 0."

The nuance I'd like to riff on is that there are Good People doing the Best They Can with the Bad Tools They Gotta Use but even they realize that, "heck this code is most likely going to have to change a lot over time, and reworking the code as you go along to deal with those changes means a lot of managing repetitive ASCII because our languages suck," and so the Siren song to use the global (or whatever other evil shortcut) becomes all the more alluring.

No comments:

Post a Comment