A lot of times, languages like Lua get introduced by enthusiasts in a way that others have to touch when things break but not enough to master. Think of shops that have those one off Perl scripts and the challenge with touching them.
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
> When we started Lua, the world was different, not everything was C-like. Java and JavaScript did not exist, Python was in an infancy and had a lower than 1.0 version. So there was not this thing when all the languages are supposed to be C-like. C was just one of many syntaxes around.
> And the arrays were exactly the same. It’s very funny that most people don’t realize that. There are good things about zero-based arrays as well as one-based arrays.
> The fact is that most popular languages today are zero-based because of C. They were kind of inspired by C. And the funny thing is that C doesn’t have indexing. So you can’t say that C indexes arrays from zero, because there is no indexing operation. C has pointer arithmetic, so zero in C is not an index, it’s an offset. And as an offset, it must be a zero — not because it has better mathematical properties or because it’s more natural, whatever.
> And all those languages that copied C, they do have indexes and don’t have pointer arithmetic. Java, JavaScript, etc., etc. — none of them have pointer arithmetic. So they just copied the zero, but it’s a completely different operation. They put zero for no reason at all — it’s like a cargo cult.
For example, he talks about how (a < i ≤ b) is unnatural, but then fails to mention that this happens with 0-based indexing when we have to iterate backwards.
One example is when you're processing arrays or matrices in blocks. Using right-open intervals (also the most elegant option) you end up with intervals like [0, 4) [4, 8) [8, 12). Pretty trivial to calculate those bounds! It's just 4N.
With 1-based you end up adding and subtracting 1 all over the place.
Another example is indexing into flattened arrays. To get to the relevant element it's just (row_len * col + row). With 1-based indices it's (row_len * (col - 1) + row).
Basically I've done a lot of 1-based programming (in Matlab), and you definitely end up adding and subtracting 1 in places where you wouldn't need to with 0-based programming.
Due to this, the string and "sequence" libraries (which works as a Lua-like vector), and the table library in the future, are 1-based.