Hacker News new | past | comments | ask | show | jobs | submit login

Just like in math, and Lua doesn't do manual memory management so aligning stuff with memory addresses is not needed.

They're both valid options and it's just about preference.




> Just like in math

I might be wrong, but I think math favors different starting indices based on the subject matter. I've seen Analysis textbooks favor 0 as the starting index. I don't think there's a clear argument for cultural transference from math.

I'm opposed to starting index from 1 because I think departure from very mainstream programming tradition should have a strong reason beyond preference, even if the de facto tradition appears equally capricious.


There are good reasons for zero-based indexing outside of pointer arithmetics: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...


It's a well-known argument. It's also widely recognized as highly subjective, starting with the notion that upper bound must be exclusive.


Indexing starts at 1 in math mostly because in history, people were afraid of 0, and it's hard to change conventions.


Debatable. It makes sense to say "the first element", regardless of mathematical connotations. We've had this kind of expression in almost every language across the world long before we invented multiplication.

Saying the "the zeroth element" is just... weird and slightly nonsensical.


Yes, because language developed at a time where people didn't know about zero.


Zero still would most likely wooldn't make sense. Zero is nothing, it can't be anything. Even ordinally.

1 is something and it fits very well for the first position... outside of programming :-)


In 1-based indexing, the index of an item is the number of items you've already seen, including the one you're looking at.

In 0-based indexing, the index of an item is the number of items you've already seen, excluding the one you're looking at.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: