this post was submitted on 11 Feb 2025
939 points (96.8% liked)

Programmer Humor

20499 readers
1558 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 31 points 3 days ago* (last edited 3 days ago) (3 children)

GTFOH with that. 1-indexed arrays?! You monster.

(Mostly joking... Ok, somewhat joking :P )

[–] [email protected] 38 points 3 days ago (4 children)
[–] [email protected] 49 points 3 days ago (3 children)

Lua had been banned from the chat

[–] [email protected] 20 points 3 days ago (3 children)

In Lua all arrays are just dictionaries with integer keys, a[0] will work just fine. It's just that all built-in functions will expect arrays that start with index 1.

[–] [email protected] 14 points 3 days ago

Your argument isn't making me any happier - it just fills me with more rage.

[–] [email protected] 8 points 3 days ago (1 children)

That's slightly misleading, I think. There are no arrays in Lua, every Lua data structure is a table (sometimes pretending to be something else) and you can have anything as a key as long as it's not nil. There's also no integers, Lua only has a single number type which is floating point. This is perfectly valid:

local tbl = {}
local f = function() error(":(") end

tbl[tbl] = tbl
tbl[f] = tbl
tbl["tbl"] = tbl

print(tbl)
-- table: 0x557a907f0f40
print(tbl[tbl], tbl[f], tbl["tbl"])
-- table: 0x557a907f0f40	table: 0x557a907f0f40	table: 0x557a907f0f40

for key,value in pairs(tbl) do
  print(key, "=", value)
end
-- tbl	=	table: 0x557a907f0f40
-- function: 0x557a907edff0	=	table: 0x557a907f0f40
-- table: 0x557a907f0f40	=	table: 0x557a907f0f40

print(type(1), type(-0.5), type(math.pi), type(math.maxinteger))
-- number	number	number	number
[–] [email protected] 4 points 3 days ago

PHP did that same thing. It was a big problem when algorithmic complexity attacks were discovered. It took PHP years to integrate an effective solution that didn't break everything.

[–] [email protected] 10 points 3 days ago

Fortran angrily starts typing...

[–] [email protected] 5 points 3 days ago (1 children)

Don't do my boy Lua dirty like that >:(

[–] [email protected] 15 points 3 days ago (1 children)

I always felt that Lua was a girl

[–] [email protected] 19 points 3 days ago (1 children)

Lua - Portuguese feminine noun for "moon", coming from the Latin "luna"
Luna - Latin, feminine noun (coincidentally identical to the Italian noun, also feminine)

Yup, Lua is a girl.

[–] [email protected] 2 points 9 hours ago

Luna is also same as the spanish noun, also feminine

[–] [email protected] 3 points 3 days ago

Writing Lua code that also interacts with C code that uses 0 indexing is an awful experience. Annoys me to this day even though haven't used it for 2 years

[–] [email protected] 1 points 3 days ago* (last edited 3 days ago)

and MATLAB, Visual Basic (with Option Base 1), and SQL.

[–] [email protected] 1 points 3 days ago

This is one of the few things that I really don't like any Lua. It's otherwise pretty decent and useful.

[–] [email protected] 4 points 3 days ago (1 children)

Visual Basic used to let you choose if you wanted to start arrays at 0 or 1. It was an app-wide setting, so that was fun.

[–] [email protected] 1 points 3 days ago (1 children)

I've not heard that name in a long time...

[–] [email protected] 2 points 3 days ago (1 children)

It's how I got into programming, so I'll always have a soft spot for it. Now it's over 20 years later and I'm still coding.

[–] [email protected] 1 points 3 days ago

Apple Basic (on an Apple IIe) was my first language that I recall.

Didn't have a computer powerful enough for VB until later. It does have a special place in my nostalgia zone but has also led so many astray.