4 ms·
Global variables are evil. Environment variables are global variables. Lord knows how much time I’ve wasted helping people figure out why something works on one
by forrestthewoods 6y ago
Global variables are evil. Environment variables are global variables. Lord knows how much time I’ve wasted helping people figure out why something works on one machine but not another. The answer is often because they had something in some obscure envvar that may have been set once upon a time by lord knows what.
The alternative? Users launching a program should explicitly specify configuration information. Choose sane defaults. Let them be configurable via cmdline args or a config file. Ideally both. An explicitly specified config file is so much cleaner than envvar imho. Scripts that locally override global envvar is super sketch, hidden, and error prone.
TBH I think the fact that Docker exists is testament to the INSANITY of Linux environment configuration. It’s so incredibly hard to reliably launch a program that we built ecosystems of containers to encapsulate system wide configuration. And even that is hard and error prone.
- pjc50 6y ago> It’s so incredibly hard to reliably launch a program This is just silly. Global state is inevitable. If it's not in the environment it would be in the filesystem or the Windows registry.
- forrestthewoods 6y agoWindows registry is also evil. Because it’s basically the same thing. Global state may be inevitable. But that doesn’t mean you should throw the towel and sprinkle global state all over the place. You should try really really hard to have the barest minimum global state. You might be surprised how little you actually need.