Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Do you use global variables?

I think there’s a time and place for globals and many scripts are fine to use them. I do prefer scoped variables, classes, objects, etc but sometimes a single global variable has its uses. I was probably influenced by anti-global talk from other programmers and ended up not using them as much. However if you use them, you just have to understand how they work and be mindful.

This article below dives into how globals aren’t technically the issue, it’s the person coding that creates issues by mishandling globals. That might be obvious and the unsaid part of the “never use globals” thought.

https://codestyleandtaste.com/globals-ar...oblem.html
In Livewire Globals are a requirement so I definitely use them. I also don't personally think Globals in general are bad aslong as you're not going apeshit with them and if you're a solo dev working on your own stuff theres not really any issues with coding whatever way you want imho. Theres actually one of those tech SaaS gurus on Twitter and he puts literally everything inside 1 file and bro generates like $100k+/m.

The reality is, coding solo = do whatever the fuck you want, coding in a team = conform or die 🔪
I do use globals occasionally, but only after careful consideration. The potential for introducing negative dependencies is significant, so I try to be conservative.

But globalists use them exclusively all the time, I've heard. 😆 (Forgive my strange sense of humor.)
[Image: SIGNATURE.png]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[The Academy] by padrinoJun 14, 2025 02:42 AM 1 196 Jun 14, 2025 02:42 AM
Last Post: Bastille
[Help] by SIM-587985Jan 24, 2023 06:41 AM 1 145 Jan 24, 2023 06:41 AM
Last Post: HFDone
[Lua] by TurbeszMar 4, 2021 10:35 PM 1 234 Mar 4, 2021 10:35 PM
Last Post: Obscure