Detailed Notes||5m 12s
Jonathan Blow on Global State in Programming
https://www.youtube.com/watch?v=ogHl_OwcZWEHere are detailed notes from the transcript:
Main Topics Discussed:
- The Nature of Global State in Programming: The idea that every problem inherently possesses a "natural amount" of global state, which varies widely.
- Critique of Global State Avoidance Dogma: An argument against the extreme view that global state should always be minimized or eliminated, highlighting its impracticality for certain problem domains.
- The Danger of Self-Deception and Propaganda in Engineering: The core argument that adherence to un-reality-based programming dogmas leads to engineers lying to themselves, hindering effective cost-benefit analysis and good engineering practice.
- Critique of Programming Culture and Education: A broader commentary on how programming culture and educational institutions often propagate un-reality-based heuristics and "propaganda."
Key Points and Arguments:
-
Natural Amount of Global State:
- Every problem has a "natural amount of global state," which can be zero (e.g., simple factorial calculation) or "huge" (e.g., video games).
- It's crucial to distinguish between read-only global state (often unproblematic, like compiled-in constants) and modifiable global state (the common concern).
-
Singletons are Global Variables:
- The speaker dismisses the common practice of using singletons as a way to "avoid" global variables, stating emphatically that "a singleton is just a global variable." This is seen as a form of self-deception.
-
Consequences of Incorrect Global State Management (Both Extremes):
- Too much or poorly managed modifiable global state: Can make a program messy and cause bugs.
- Pretending no global state should exist (extreme avoidance): This is "stupid," makes programs "too complicated," and "affect[s] your engineering ability."
-
Good Engineering Requires Reality and Cost-Benefit Analysis:
- A good engineer needs "clear eyes on reality" and must perform a "very clear cost-benefit analysis at any given time."
-
The Real Danger: Lying to Oneself / Propaganda:
- The primary problem isn't just having a "wrong opinion" about global state, but falling victim to "propaganda" inherent in programming culture.
- This leads to programmers "lying to themselves all the time to maintain the propaganda."
- Example: Believing that doing "a lot of extra work" to avoid global state somehow made the program "so much better," even if it didn't improve actual outcomes.
- This self-deception prevents "observing what actually happened" and thus prevents good engineering. It's described as "the downfall of everything."
-
Inherent Cultural Propaganda in Programming:
- The speaker asserts that it's "inherent to programming culture that we get propagandized."
- Example: Object-Oriented Programming (OOP): Historically, OOP proponents were "so sure that you're an idiot if you don't use object-oriented programming," which only made sense "if you're like deep into the cult." The speaker notes that since OOP is "not in vogue anymore," it's easier to criticize, but he personally experienced its downsides ("I get it, guys. I've done it. It sucks").
-
Fear of Global State and Unrealistic Heuristics:
- People tend to fear global state often because they "do not know the requirements and play what if games."
- The "heuristics" programmers learn (from universities, online articles) are often "not very reality based."
Important Facts or Data Mentioned:
- Factorial computation: Cited as an example of a problem with naturally very low or zero global state.
- Video games: Cited as an example of a problem with a "huge" natural amount of global state.
- OOP's decline in vogue: Mentioned as a cultural shift that makes it easier to critique OOP now compared to 15 years ago.
- Speaker's personal experience: Studied programming in college, learned things he later had to "unlearn," and was "lying to myself about that stuff for the first several years that I was a professional game programmer."
Conclusions or Recommendations:
- Embrace Reality over Dogma: Programmers and engineers must prioritize "clear eyes on reality" and objective cost-benefit analysis over rigid ideological adherence to programming paradigms (like absolute avoidance of global state).
- Guard Against Self-Deception: Be critically aware of tendencies to lie to oneself to justify adherence to certain practices, as this undermines effective engineering.
- Critically Evaluate Learned Heuristics: Question the "heuristics" learned from education and online sources, as they may not be "reality based."
- Unlearn Damaging Beliefs: Be willing to "unlearn" previously held beliefs that prove detrimental or unrealistic in practice.
- Understand Requirements: Address the fear of global state by deeply understanding the actual requirements of a problem, rather than engaging in hypothetical "what if" scenarios.
Generated with Tapescript