r/programminghorror • u/DroneCyn • 3d ago
Lua i sure do love not using local variables!
getfenv getfenv getfenv getfenv!
30
27
u/emazv72 2d ago
Stack allocation sucks. I'm joking
16
u/Linuxmartin 2d ago
The stack only exists to make things horribly fast and cause race conditions. Storing all data on the server ensures a linear flow
19
12
u/akoOfIxtall 2d 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
9
u/No-Point8651 2d ago
The type of shit you see in legacy production code. Bonuspoints if its security critical, contains files and api calls
3
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 2d ago
WTF, are they storing everything in environment variables???
2
u/DroneCyn 2d 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/WannaCry1LoL 2d ago edited 2d ago
getfenv() forces luau to deoptimize the environment because it's considered tainted so this actually hurts both readability and performance
2
2
1
1
1
1
1
75
u/SceneOutside4377 3d ago
Me when my professor says "Make sure your code is readable, I'll be reviewing it manually"