Hacker News new | past | comments | ask | show | jobs | submit login

Humans don't start counting at zero, though―we start counting at one. Zero, in fact, was a concept introduced to our arithmetic much later.

A list of twenty items has a twentieth item.

Dijkstra is far too mathematical with this―no student learning programming for the first time (edited: changed from programmer) in the world ever thought "arrays starting at 0―how natural!".




But indexing is not counting. It bears some similarity to measuring, though. If you look at a ruler, does it begin with a "1"? Or does it have a "1" one unit from the beginning?


Indexing is only "not counting" when you're working with a base address and an offset. In most languages, that's only an "under the hood" reality; the programmer is neither interested in, nor has direct access to, the bitly goodness underlying the array (or what have you). It's just a bunch of slots, and when you want to put something into (or take something out of) the first slot, then the natural ordinal is "first", not "zeroth". We're just used to a different way of doing things; it doesn't make any more sense to anyone, except by convention.


It IS counting when it measures discrete elements, and it is measuring when it measures distance from a boundary. Discrete sets and continuous sets are very different beasts, and some of the mix-up here seems to be from ignoring their differences.


You might change it again to "no programmer of language without direct access to memory pointers". Then again, even that would be hard to prove. I definitely didn't see anything wrong with starting at 0 and it made perfect sense for C arrays.


> arrays starting at 0―how natural!

Better than starting at pi; that would be irrational.


Think about that:

A clock starts at zero. A day has 24 hours but there is not a twenty-fourth hour. Midnight is 0:00.


Clocks are a relatively recent invention.


In fact Clocks are one of the oldest inventions of the human mind. 4000 years ago in Babylon water clocks (clepsydra) were used. Also in old China. http://www.nist.gov/pml/general/time/images/water_1.gif There is a 2050 year old Horologia tower in Athen ("Tower of the Winds"):

"This structure tracked a 24-hour day using both sundials and mechanical hour indicators"


Humans have been around for more than 200,000 years (up to 2.5 million years, depending on how you define the term "human"). So even 4,000 years ago is relatively recent on the scale of human history.


I'd disagree with your last statement. I enjoy the mathematically simplicity of the address into your array being pointer+size(index) as opposed to pointer+size(index-1). Now I will agree that it's probably because of too much math, but it just makes sense that if I want to drop out a term I can multiply it by zero. It's like finding roots of polynomials.


I actually meant programming student, as in, student learning programming for the first time―naturally, once we reach a certain level of proficiency, more of the esoteric concepts seem intuitive to us; I've edited my post accordingly.

You're right that it is convenient that the address of an item is first index + current index * index size in memory, but things like that comes at a cost of making indeces completely unintuitive.


You're (probably) right, and no student learning programming for the first time thought that starting array indexes at zero was a natural idea.

That is because they are learning it for the first time.

Another way of putting that might be that they don't know a single thing about the subject ;)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: