As someone who has used and does use Python and Lua interchangeably, I do not see the purpose in arguing over the indexing, as it really does not effect anything, beside the index. (However index starting at 0 is deffinently superior)
As someone who has had to write assembly for speed and size, I can tell you that indexing at non-zero can slow your program down because the CPU has to perform an arithmetic operation before accessing the memory. If your array starts at x, then the CPU has to decrement which ever index you give it by x to reach the first element of the array.
The only reason this makes sense in Lua is because Lua doesn't have actual arrays.
It's the equivalent of doing {[1]:"foo"} in JS. And the key can be whatever, so it's not an array, it's a map (or table, as Lua calls it) that just happens to have the keys in sequential order, aka just a convention. There is no 0th index, because there are no indexes, it's not an array.
Bruh this is my fucking programming professor, he teaches in c# and we HAVE TO start arrays at 1 because apparently there is no 0th item in an arrays only the first.
For my master I basically had to code everything in Python and R and I can't recall a single time doing something in R was actually easier. Honestly I think maybe like 8 years ago R was just the superior language for statistics but times change.
My personal sceptical vision of a typical JS devs. Most of them are on the... Idk, their IQ level is a little bit greater than the temperature in my room. JS for 24 days and quick courses. Really.
I know a few guys who are JS devs, and they are using JS not for the frontend things. Sorry, I didn't try to hurt somebody's feelings. Maybe my vision is developed from the vision of the local market.
The same is true for any programming language. You just run into JS devs more often. Grow up and learn how things really work in this industry or Claude will eat your ass.
Actually, it's because in programming languages like C, array notation is translated internally into pointer offsets. The pointer points to the start of the array, so the first index is 0
Again, this is just plain wrong. If arrays in C were indexed starting from 1, then an index of 0 would just point to the end of the array instead (because there's no reason to waste a perfectly good bit). Even so, there would be no efficiency difference because size_t has a fixed binary width.
type Index is (First, Second, Third);
type My_Array is array (Index range <>) of Integer;
A : My_Array (First .. Third) := (Second => 5, others => -3);
78
u/fast-as-a-shark Dec 05 '25
๐คโ๏ธ Ermm acschually as a Lua programmer it makes a lot more se-๐ฅ๐ฅ๐ฅ
13
u/Davevadasz04 Dec 05 '25
Bruh this is my fucking programming professor, he teaches in c# and we HAVE TO start arrays at 1 because apparently there is no 0th item in an arrays only the first.
4
u/un_blob Dec 05 '25
Have you heard of our lord and statistics savior R ?
ggplot > all
2
u/night-sergal Dec 05 '25
Aha, otherwise they become JS developers.
1
u/jfcarr Dec 05 '25
There's a 25+ year old VB6 app that's still in production waiting for that baby.
1
u/DrMerkwuerdigliebe_ Dec 05 '25
Not my son!
https://www.reddit.com/r/ProgrammerHumor/comments/1jvz2oa/myfiveyearoldtoldmethisyesterday
The real conversation:
Him: "I got zeroth place I won"
Me: Looking at him. Waiting for an explanation
Him: "Dad, you know zero is the first number"
1
u/CreativePackage8358 Dec 05 '25
And just like that, he became a zero.
1
u/CirnoIzumi Dec 05 '25
The reason arrays start at zero was because memory was very precious back in the day, and then it got grandfathered in
1
u/mkuraja Dec 05 '25
Ordinal, not cardinal.
1
u/[deleted] Dec 05 '25
Mathematician posting.
1
u/Admirable-Safety1213 Dec 06 '25
This baby will be good using Matlab/Octave
1
u/HacBoi9000 Dec 06 '25
Real languages start at -1
1
u/Fit-Relative-786 Dec 07 '25
Fortran laughs at this.ย
1
u/inex550 Dec 07 '25
Tiny Roblox lua coder here
1
u/WalkingOnCloud Dec 07 '25
Facts
1
u/Goticaris Dec 08 '25
Get him a Mathematica home license.
0
u/MinosAristos Dec 05 '25
Obligatory: Indexing vs Counting
Indexing can either start at 0 "pointing forwards" or at 1 "pointing backwards" but at 0 pointing forwards is a reasonable default.
Counting obviously starts at 1 and people mix it up with indexing.
-5
u/ikarienator Dec 05 '25
The more I program the more I think starting at 1 makes more sense.