Hacker News new | ask | show | jobs
by pfedak 2798 days ago
I was hoping to read some code analysis that supported your claim of off-by-one being more common in 0-based languages, but all I see in your [3] is a few different speculative reasons - am I missing something?

Off-by-one can show up in a bunch of ways that are agnostic to the underlying indexing, so it isn't obvious to me that there would be a substantial difference at all. Also, given what's said below about the ease of writing code which fails to consider custom indices, I'm not sure I believe just switching to 0-based or anything else in Julia is as painless as you suggested earlier - it could introduce its own off-by-one errors!

1 comments

Agreed. Off-by-one often shows up when calculating indexes e.g. differences in indexes or offsets. These calculations are independent of the base of the index (0 or 1 or even N).