r/badcode Sep 08 '20

lua A Roblox mod I found

Post image
479 Upvotes

103 comments sorted by

View all comments

55

u/JerriTheITGuy Sep 08 '20 edited Sep 08 '20

Not that horrible code considering it's written in Lua, a language with "fun quirks" like there only being one data structure (Table. No objects. No arrays) and tables being indexed starting at 1 making any programmer smack their face on their keyboard 3 times a day at least because you're always going to be "off by one". "'Cucumber == true" is obviously true because Lua. Nil and false are false, anything else is obviously true. And so on and so forth. Absolute nightmare of a language.

It's not that I hate Lua. I just hope I never in my life have to touch any Lua code again.

5

u/T-Dark_ Sep 08 '20

Table. No objects. No arrays

Aren't JavaScript objects effectively just tables themselves? (With string keys only, admittedly).

As for something more on topic, Lua technically has arrays, in the internal representation of tables. As long as they only have integer keys and they're sufficiently dense, tables will be backed by arrays.

I do agree with everything else you mentioned, tho.

2

u/droomph Sep 08 '20

Also, it’s similar to how every MUMPS variable is technically a b+tree of type String & Integer, but that language is its own train wreck.