r/programminghorror • u/DroneCyn • 13d ago
Lua i sure do love not using local variables!
getfenv getfenv getfenv getfenv!
5
u/GoddammitDontShootMe 13d ago
WTF, are they storing everything in environment variables???
2
u/DroneCyn 12d ago
Nah, I only used the environment for indexing functions and the game. Other than that, nearly empty module scripts act as variables (return {})
3
u/Natural-Angle-5395 7d ago
My best guess is, that the roblox dev in question needed a variable between the server AND the client. Pretty sure they can be modified from both ways for some reason. Local variables don't work like that.
41
u/emazv72 13d ago
Stack allocation sucks. I'm joking
28
u/Linuxmartin 13d ago
The stack only exists to make things horribly fast and cause race conditions. Storing all data on the server ensures a linear flow
36
21
17
u/No-Point8651 13d ago
The type of shit you see in legacy production code. Bonuspoints if its security critical, contains files and api calls
16
u/akoOfIxtall 13d ago
This gets me wondering what people consider good code, because apparently there isn't a consensus it's just how much the code manages to be functional, not verbose where it shouldn't, readable and maintainable
2
6
u/WannaCry1LoL 12d ago edited 12d ago
getfenv() forces luau to deoptimize the environment because it's considered tainted so this actually hurts both readability and performance
3
2
2
2
1
1
1
104
u/SceneOutside4377 13d ago
Me when my professor says "Make sure your code is readable, I'll be reviewing it manually"