This is a question which I have wondered (and been asked) about for a long time.
In (most? all?) programming languages, an index begins at zero for an array, string, etc. I recognize it became convention over time, adopted in many languages, but can anyone point to the origin of this?
I thought, perhaps, it had to do with all being rooted in binary. But I am not sure of the idea carrying to the necessity in the decimal system -- why not start an index from 1?
Does anyone have historical knowledge of programming languages where the decision to begin indexes at zero may have been explained?
Thank you!
EDIT: The Dijkstra writings are further helpful from a mathematical standpoint, but even has he noted, not all languages are zero-indexed. WBT's explanation also makes sense as to why one would start with zero based on memory addresses. (I know some languages handle indexing slightly different based on array manipulation.)
I'm not necessarily looking for the why (which I very much appreciate because it helps further an understanding) but more along the lines of when did this become the convention and/or whether it can be traced to a specific language.
So, for instance in K&R's C, when discussing array indexes, K or R matter-of-factly explains, "Array subscripts always start at zero in C..." (p. 22) Later, in discussing a function to process character arrays, "... a more useful design would be to return the length of the line, or zero if end of file is encountered. Zero is an acceptable end-of-file return because it never is a valid line length." (p. 127)
Based on K&R, I gather a) the convention is adopted from elsewhere, so C is not the inspiration behind zero-indexing and b) there are possibly deeper reasons for its use based on the second example. I know K&R is so widely regarded for its clear prose, so that's another reason I include it, to give an example of what I had hoped another documented language would do to explain the reason behind zero-indexing.
I think both WBT and btilly offer equally good reasons; I wondered if anyone who perhaps knew old (pre-C?) languages which documented the design decision. And at the same time I recognize such information may not exist.