If you want first element of list or array you reference it as 0 in many languages (like C or Clojure). Is there are some really good reasons why the programming languages was design this way?
In old days in assembly languages it makes perfect sense because all possible values needs to be used.
But what are nowadays to keep it this way? There is very little advantage when modulo arithmetic and ranges (Wikipedia article.) but not much more.
On a disadvantages side it should be: It makes confusion because it human language the first is connected with 1 (1st and it is not in english only). It makes confusion even in XPath (W3School:”Note: In IE 5,6,7,8,9 first node is[0], but according to W3C, it is [1].”). There are troubles between languages who use 1-based and 0-based system.
Want to know hat are the good reasons to use zero-based numbering and why even creator of new languages (like Clojure) choose this way?
6
Yes, there is a reason:
If you have a 1-based address, the starting (first) element of array anyway lies at zero address. It is a contradiction, that disappears if you have a 0-based address. And for the last you have one operation less when counting the address of the element. So, C in array addresses counting is more effective than much older 1-based FORTRAN-4.
Of course, in ours days the reasons must be based on human convenience. And counting row = natural numbers sequence starts at 1. And anyone of us started to count from 1 in childhood.
But people who makes new languages are thinking on two more reasons – grammatic simplicity of the language and customs of probable future users. And if you want to get C users, you’ll introduce 0-based address.
And, of course, one more, purely subjective reason – language authors can simply like or dislike one of these schemes.
9