What's the big deal? 0 vs 1 based indexing

0-based indexing actually becomes very natural when you program for long enough and doesn’t use any intellectual capacity at all. In fact, when working with 1-based languages I have to constantly remind myself that they are 1-based and keep messing things up even when I’m actively thinking about it (talk about error-prone).

I think 0-based indexing makes quite a lot of sense in many scenarios, especially when dealing with algorithms and such (getting the root of an array-based binary tree works very easily by dividing by 2, but only on a 0-based array, spatial partitioning becomes easier as well, etc.), not to mention actually working with memory, where the index is really just an offset and adding a 1 to it would only serve to make things messy.

1 Like