The first case just sounds like blatant failure to address what can be fairly obvious implementation flaws. For the framework I’m using, AeroGameFramework, it reserves a single “namespace” in _G (_G.Aero). There’s an almost zero chance of any of that overlapping nonsense. There’s one bootstrapper that sets everything up and every other variable waits for the strapper to assign _G.Aero rather than trying to declare.
Repository if you’re interested and don’t have the link:
I think _G on Roblox still has use so long as you address what can be fairly obvious issues. That’s as far as your own code goes though. On the other hand, I completely agree with the point you’re raising. _G can get especially troublesome for OSS that doesn’t appropriately sort their resources and dependencies (e.g. like Aero, having a single table represent all of the framework’s globals).
To elaborate on the above a bit: as far as Roblox goes (since I do know there’s the whole “no to global variables” with other languages), it’s completely fine if your software defines a table within _G and then uses that for any global variables.
_G.MyFramework = {
Something = {},
OrTheOther = {},
}
-- or
local MyFramework = {
Something = {},
OrTheOther = {},
}
_G.MyFramework = MyFramework
What starts becoming painful is if there’s a lack of sorting and code hogs the first dimension of _G.
-- The readability on this is terrible anyway
_G.Something = {}
_G.OrTheOther = {}
As for _G in general being global, you could assign your corner of dependencies over to a local variable. That would dismiss the whole global argument, would it not?
local MyFramework do
while not _G.MyFramework do wait() end
MyFramework = _G.MyFramework
end
Please do point something out if I’ve made a disagreeable remark, I’m sort of just volleying ideas here since I never genuinely understood the _G war for Roblox. For other languages it may be a different story but Roblox essentially takes the development process and greatly simplifies it, which is why I find that _G on Roblox is fine so long as it doesn’t become habit in other languages.
All in all though, if you have a framework, you don’t have much use for _G, since your strapper would be requiring modules and sending your tables and such to modules from a main source point. The only reason you’d actively need _G is for external script access which botches the idea of single-script architecture.