Article:
  What I Hate About Your Programming Language
Subject:   C, C++, Java, maybe others - zeroth element arrays
Date:   2003-05-14 17:50:13
From:   anonymous2
Response to: C, C++, Java, maybe others - zeroth element arrays

You and all the other replies seem to forget
the most important thing: an array index measures
the distance of the element from the beginning
of the array. If you think otherwise, try to
write a piece of code that maps a 6 dimension
array into a the memory (which is a one dimension
array) in a language that starts indexing with 1.


The mess that you will see is the reason why it
is better to start with 0. Also, if you like
starting with 1, cut off the 0th inch from all
of your rulers and measuring tapes and try to build a shed (or do any job where you have to
measure things). I would like to see the result
or how far you get.

Full Threads Oldest First

Showing messages 1 through 3 of 3.

  • C, C++, Java, maybe others - zeroth element arrays
    2003-05-15 11:55:38  anonymous2 [View]

    "You and all the other replies seem to forget
    the most important thing: an array index measures
    the distance of the element from the beginning
    of the array."

    First of all, the distance is not the element number, it is the multiple of the element number times the size of an individual element in bytes.

    Regardless of that, here is where I disagree with you completely. The array index is for the PROGRAMMER. The offset is for the MACHINE. Becoming accustomed to thinking this way has nothing to do with the original point - which was that this is bending the humans to the machine rather than the other way around.
  • C, C++, Java, maybe others - zeroth element arrays
    2003-05-15 00:33:37  anonymous2 [View]

    This is like saying a hole in the ground is better than a flushing toilet, it is giving you what you want and is less difficult to implement. And what if you are on rocky ground?

    I do not need to care about implementing multidimensional arrays into memory (that's the compilers task, right?), I just want to express my thoughts in the language easily. No cupboard in my house has a zeroth shelf.
    • C, C++, Java, maybe others - zeroth element arrays
      2003-05-15 03:52:41  anonymous2 [View]

      No, the cupboards in your house may not have a zeroth shelf, but they DO have bottom shelfs, which are really just the analog of the array index 0, in terms of sequence. In fact, I would propose that there really isn't a zeroth element in an array, aswell. (Much to the chagrin of what the "zeroth" jargon file entry author might have to say, I might add.)

      Zero is the offset from the beginning of the array that you use to access the First element. Perhaps there is an inevitable blur in the distinction between the indexer and the indexee when dealing with arrays.

      When conceptualising the digital representation of an array for your cupboard analog, you must note that it is neither wrong, nor right to assert that the first element in the array starts at 0; it is rather tradition, but useful nonetheless. Consider the following:

      In Python, for instance, you can access the last element in the array with the value -1. If the first element were 1, then accessing the last element via 0 would seem rather unnatural, both mathematically and practically, as access is being performed with offsets in mind.

      At the end of the day, it all boils down to the age-old philosophical quandary of the "half-filled cup" perspective. Either you approach the issue from the viewpoint that you are accessing the first element, with the quantitative equivalence of 1, or you are accessing the first element at the offset from the bottom/start of the array, or the sequential equivalence of 0.

      Trying to convince anyone that they are wrong in this matter is simply a fool's toil.