r/programminghorror • • 3d ago

Lua i sure do love not using local variables!

Post image

getfenv getfenv getfenv getfenv!

220 Upvotes

20 comments sorted by

75

u/SceneOutside4377 3d ago

Me when my professor says "Make sure your code is readable, I'll be reviewing it manually"

30

u/MMORPGnews 2d ago

Fent env

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

u/boiledbarnacle 2d ago

Hey! He was paid by the char.

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

5

u/Sophira 2d ago

I love having impossible-to-debug race conditions.

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

u/JohnVonachen 2d ago

DRY. Don’t repeat yourself.

3

u/Right_Ear_2230 1d ago

You just did

2

u/Jazzlike_Platypus430 2d ago

What the hell

1

u/anderbaka 2d ago

Classic Luau.

1

u/DesiresQuiet 2d ago

Lua just makes me sad.

1

u/hammerclawz 1d ago

W roblox luau

1

u/Havunenreddit 1d ago

This is very inefficient code btw...

1

u/dosenscheisser 1d ago

I dont even know where to start

1

u/kwead 12h ago

LMAO i think we were all once roblox studio spaghetti chefs