The Only Good Global Variable Is a Commented-Out One
Description
This image is a screenshot of a tweet by a user named Richard (@zzaaho). The tweet is structured as a simple Q&A. The question is, 'Q: What is the best prefix for global variables?'. The answer provided is, 'A: //'. This is a highly technical and witty joke for experienced developers. Global variables are generally considered bad practice in software engineering because they can be accessed and modified from anywhere in a codebase, leading to unpredictable behavior, hidden dependencies, and debugging nightmares. The joke's punchline, '//', is the syntax for a single-line comment in many popular programming languages (like C++, Java, C#, and JavaScript). Therefore, the 'best prefix' for a global variable is to turn it into a comment, effectively advising against its use altogether. The humor resonates with senior developers who have experienced the pain caused by global state
Comments
17Comment deleted
Global variables are like public restrooms. They're convenient when you need one, but you never know who used it before you or what state they left it in
Our coding standard says every global must start with “//” - it keeps the linter silent, the architect’s blood pressure stable, and reminds future archaeologists that even our singletons didn’t deserve runtime
The same architect who insists on proper dependency injection will defend that one global config object like it's their firstborn child
The real tragedy isn't that global variables exist - it's that after 15 years of architecture reviews, you still find them lurking in production code like undocumented legacy endpoints. At least with '//' you're being honest about their lifecycle: deprecated on arrival, yet somehow still in the codebase during the next major refactor
Globals: the shared mutable state that haunts multithreaded monoliths, best exorcised with a // prefix
Globals are a distributed cache with no TTL - choose //, or choose on-call
Best prefix for global variables? // - restores referential transparency and lets on-call sleep
Python programmers: I think it isn't Comment deleted
And Ruby Comment deleted
Or /* if you like to break things Comment deleted
The best prefix for the whole shitty code Comment deleted
Yes Comment deleted
dont_use_or_you_will_be_fired_ Comment deleted
What is the correct answer then? LOL Comment deleted
writes shitty, buggy code of course it's those pesky global variables Comment deleted
😂😂😂😂😂😂 Or /**/ Comment deleted
/**/ float g_globalVariable = 1.0f; xD Comment deleted