this post was submitted on 11 Feb 2025
574 points (97.5% liked)
Programmer Humor
20039 readers
1575 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
- Keep content in english
- No advertisements
- Posts must be related to programming or programmer topics
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
GTFOH with that. 1-indexed arrays?! You monster.
(Mostly joking... Ok, somewhat joking :P )
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.
I've not heard that name in a long time...
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.
Lua has entered the chat
and MATLAB, Visual Basic (with
Option Base 1
), and SQL.This is one of the few things that I really don't like any Lua. It's otherwise pretty decent and useful.
Lua had been banned from the chat
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.
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.
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:
Your argument isn't making me any happier - it just fills me with more rage.
Fortran angrily starts typing...
Don't do my boy Lua dirty like that >:(
I always felt that Lua was a girl
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.
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
How is arrays starting at 1 still a controversial take. Arrays should start at 1 and offsets at 0.
Arrays are address offsets.
So what's 0 do then? I'm okay with wacky indexes (I've used something with negative indexes for a end-index shorthand) but 0 has to mean something that's actually useful. Using the index as the offset into the array seems to be the most useful way to index them.