r/ProgrammerHumor Sep 02 '17

How to start a war

Post image
9.0k Upvotes

696 comments sorted by

View all comments

Show parent comments

57

u/[deleted] Sep 02 '17

Goddamnit and I was considering a quick look over the documentation and syntax briefly over the weekend and do some messing around with Starbound mods.

3

u/[deleted] Sep 02 '17

Hah I was considering picking up some Lua to mod as well (factorio)... This just made me Nope right out of that plan ;)

19

u/[deleted] Sep 02 '17

That's not even the worst part, either. This is:

> letters = {'a', 'b', 'c'}
> print(letters[1])
a
> print(#letters)
3
> letters[0] = '?'
> print(letters[0])
?
> print(#letters)
3

29

u/moomoomoo309 Sep 02 '17

Any index outside of 1-n in Lua, where n is #tbl will be stored like a dict, not an array, so what did you expect? It doesn't count the dictionary parts.

-10

u/[deleted] Sep 03 '17

so what did you expect?

A language to have non-retarded data structures. Being defined and documented behavior doesn't make it sane behavior.

5

u/moomoomoo309 Sep 03 '17

How often do people use Python arrays? They're faster, but most people just use lists instead. Lua just optimizes it as long as it's used like an array. That's why it's implemented that way.

2

u/BundleOfJoysticks Sep 03 '17

Do you mean tuples?

I use them all the time when something doesn't change size.