|
|
|
|
|
by dmz73
545 days ago
|
|
I have a really hard time understanding why people like 0 based indexes.
They are a relic of C style arrays that are based on and interchangeable with pointers which use offsets that are naturally 0 based.
Use in later languages gives us endless off-by-1 issues and rise to "for 0 to count/len/num - 1" or even better range syntax that is start inclusive BUT end exclusive.
It is a horrible cludge just to support 1970s language perfomace optimization.
Arrays should start and end at whatever start index is required, not at offset 0 of pointer to fist element of array. |
|
JS:
Lua: Don't get me wrong. I like Lua, I've made my own IDE for it, https://plugins.jetbrains.com/plugin/14698-luanalysis, but this is definitely not an argument in favour of 1-based indices.