Skip to content
DevMeme
2984 of 7590
CodeQuality Post #3294 · source on Telegram

The Unrefined Nature of Global Variables

Description

A two-panel meme from the animated series 'Family Guy' contrasts global and local variables. The top panel features the character Meg Griffin, looking exasperated, with the label 'Global variables'. Below her is the quote, 'You guys always act like you're better than me'. The bottom panel shows other members of the Griffin family - Peter, Lois, and Chris - dressed in sophisticated, formal attire, including top hats and a tiara, looking down with an air of superiority. This panel is labeled 'Local variables'. The meme humorously personifies a fundamental programming concept: the preference for local variables over global ones. Global variables, which can be accessed and modified from anywhere in a program, are often considered poor practice as they can lead to unpredictable side effects and make code difficult to debug and maintain. Local variables, with their limited scope, are seen as the cleaner, safer, and therefore 'better' choice, perfectly captured by the Griffin family's smug, aristocratic portrayal

Comments

9
Anonymous ★ Top Pick A global variable is like a public toilet: you don't know who used it last, what state they left it in, and you're pretty sure touching it will cause unexpected side effects
  1. Anonymous ★ Top Pick

    A global variable is like a public toilet: you don't know who used it last, what state they left it in, and you're pretty sure touching it will cause unexpected side effects

  2. Anonymous

    Globals keep crying class warfare, but after you’ve seen one race condition smear their stale state across 200 threads, a little stack-based aristocracy feels well-deserved

  3. Anonymous

    Global variables are like that one senior engineer who still has write access to prod from 2008 and everyone's too afraid to revoke it because half the cron jobs might break

  4. Anonymous

    This meme perfectly captures the architectural snobbery around variable scope - global variables are the Meg Griffin of programming: universally accessible, frequently modified by everyone, and constantly blamed when things go wrong. Meanwhile, local variables sit in their encapsulated ivory towers with proper lifetime management and predictable state, smugly adhering to the principle of least privilege. The real irony? Both are just memory addresses with delusions of grandeur, but one has better PR and doesn't cause race conditions at 3 AM in production

  5. Anonymous

    Globals are why your tests pass individually and flake in parallel; locals arrive with DI, reentrancy, and a clean exit

  6. Anonymous

    Global variables are shared mutable state with a company-wide blast radius; local variables are scoped, deterministic, and classy enough to leave before the postmortem

  7. Anonymous

    Globals: singletons on steroids, crashing every party. Locals: scoped nobility, zero state leaks

  8. @sylfn 5y

    Haskell: what the hell are you, variables?

    1. @azizhakberdiev 5y

      Pascal: "WTF, WHY DO YOU EXIST LOCAL SHIT"

Use J and K for navigation