3 ms·
Though I've grown up with programming languages that have zero-based indexing, I've never become a "native speaker", as I always mentally add or subtract a one
by domador 7y ago
Though I've grown up with programming languages that have zero-based indexing, I've never become a "native speaker", as I always mentally add or subtract a one as needed when trying to understand code involving list indices. Zero-based indexing may be common, but I'm pretty sure it's far from natural to most people. It is likely a main cause of many off-by-one bugs. I wouldn't blame a language designer for choosing one-based indexing instead.
- alpaca128 7y agoI don't have any trouble with it, I just imagine the index as what it is: an offset, and the first element's location has the offset 0 from the start of the array. For me it's far more confusing when I have to write code in a language with 1-based indexing, although I can see why e.g. Julia does it as it's more focused on mathematics and also in some cases the indexing is actually simpler when specifying a range.