Starting with Zero is a BAD Decision

Zero based Array is poor form.

Here is my practical experience with zero based indexing as used in the C-Family of Languages. It's just bad form! Bad because it requires much more brain power to live with the non-natural counting method. I've just sat and watched three tallented software developers struggle with the indexing problem in a kata for hours. There is no amount of time-saving a computer from an *(array + index - 1) that can make up for the countless hours of reasoning, giving up and adding a "-1" to your code, or asking a friend that saves effort of all humans.

I looked up ... FORTRAN does the natural index starts at ONE. It most likely gets blamed upon K&R (Kernighan & Ritchie). But that may be placing blame on the wrong feet. Although, they could have corrected the atrocity before it occurred. The deed was done by the predicessor to C - the B computer language and Martin Richards.

All to save the computer from having to calculate the start of the array with the "-1". Now some have argued that this calculation could be inside yet another loop, which is inside yet another 3rd dimensional loop. And this recursion could cause real delays in the processing speed of the computer. I say poppykash! How many Human hours have been lost to this decision, in the proper accounting for edge conditions, and limit conditions necessary for a human to deal with this off-by-one problem? Edsger Dijkstra ( Why numbering should start at zero) be damned! Counting starts at ONE for a very good reason - Humans!

Have you heard of the OFF-by-ONE problem? Ever experienced that predicament?

Recently in the kata "100 Doors" we spent hours fighting this issue.
Cyber-Dojo - a 100 Doors Language challenge - solve this with the C-based language - then with a proper counting language in a double-blind experiment - see which wins the programmer efficiency test.

When is the last time you heard a Fortran programmer complain about off-by-ONE?

In the late 80s I was taught that if I coded my loops backward they would execute faster. And this might be why Netware was so very fast at putting data on the wire and had to have wait states embedded in its network stack to slow it down for Windoes machines. A loop from 100 to ZERO is faster because that last compare effectively does 0 == 0; not 100 == 100.


See all the various ways of writing For Loops in Exploration in Looping.