4 ms·
Lua Rocks. (Yeah, I know...) One-based indexing is more natural, far, less error-prone, reflects real world relationships better (people starting at one, not z
by dublin 3y ago
Lua Rocks. (Yeah, I know...) One-based indexing is more natural, far, less error-prone, reflects real world relationships better (people starting at one, not zero) than zero-based indexing, which has become some kind of purity test for the worst sort of propeller-headed CompSci weenies.
Many other languages have chosen one-based indexing for the same reasons: all of them are languages that have a high incidence of dealing with real-worrd data and relationships: In addition to Lua (a beautifully elegant language) there's FORTRAN, Julia, Tcl, Awk, Mathematica, Matlab, COBOL, Smalltalk, and quite a few others. The architects of these languages made very deliberate decisions to prefer one-based indexing.
One-based indexing makes a LOT MORE sense for most real-world work, and as noted, avoids the ubiquitous off-by-one errors that pervade the unnatural zero-based indexing.