The Use and Opinions on Global Variables in Programming

Viewed 7
This discussion explores the use of global variables in programming, primarily touching on differing opinions and experiences. One comment highlights the need for two work lists, implying a potential improvement or complexity when using globals. Another user mentions that while global variables can be useful, they don't provide real advantages and that their overuse is often criticized. There’s also a contrasting view that while global variables might seem beneficial in maintaining consistency (e.g., increments in a counter), this can fail in concurrent environments. This reveals a critical evaluation of global variables, suggesting that their usage might lead to complications rather than simplifications in code, particularly in multi-threaded scenarios.
0 Answers