Global Variables Criticism

The cluster focuses on discussions criticizing the use of global variables in programming, particularly in JavaScript, highlighting issues like namespace pollution, maintenance nightmares, and alternatives to avoid them.

➡️ Stable 0.7x Programming Languages
2,325
Comments
20
Years Active
5
Top Authors
#8983
Topic ID

Activity Over Time

2007
4
2008
16
2009
54
2010
70
2011
98
2012
111
2013
169
2014
128
2015
135
2016
92
2017
126
2018
117
2019
137
2020
187
2021
180
2022
173
2023
151
2024
163
2025
208
2026
6

Keywords

e.g GLOBAL JS OK config.html JavaScript HARD ES5 github.io SO global variables var scope variable code function object request dynamic

Sample Comments

dundercoder Oct 3, 2017 View on HN

Global variables... I'm ashamed.

haberman Apr 11, 2012 View on HN

Couldn't agree more. It's like using a library that insist on putting everything in global variables.

sirwhinesalot Feb 26, 2022 View on HN

Today in why global variables are bad...

bandrami Feb 3, 2025 View on HN

How is a globally-scoped closure not a global variable?

cube00 Dec 17, 2021 View on HN

Only global scope sounds like a nightmare.

soperj Apr 13, 2019 View on HN

that's because it still has global variables.

benedictchen Jun 7, 2021 View on HN

Poor child. Wait until you have to build a sufficiently complex web app. Global variables are never the answer

caillou Apr 28, 2010 View on HN

There is a massive amount of functions and variables in the global space. That looks fishy to me.

im3w1l Oct 12, 2019 View on HN

Maybe it's fine, but I'd be concerned about polluting the global namespace

boxed Jan 23, 2024 View on HN

Waitwhat, surely it's not GLOBAL state, but "module global" or something?