Why counting should start at “zeroth”

2 points by cousin_it ↗ HN
We just had yet another big discussion of Dijkstra's "Why numbering should start at zero": https://news.ycombinator.com/item?id=13186225

The mathematical arguments for zero-based indexing made sense to me as always, but I still couldn't get over the fact that a[2] refers to the third element of the array. If truth is beauty, and beauty truth, then why does the mathematically beautiful idea disagree with common sense counting of fingers?

I thought about it for a while, and had a radical realization: Common sense counting is wrong. It should start with "zeroth" instead of "first". It's not just about programming, but even everyday things like "my zeroth cigarette". The real world has tons of off-by-one errors that trip people up, that would go away if we consistently used "zeroth" to refer to the starting element of a sequence.

Here's a powerful example:

"The first year of the third millennium begins at 2001/01/01 00:00:00."

It's confusing in so many ways!

* The year 2001 is in the third millennium?

* But the year 2000 isn't?

* Hours start from 0, but days start from 1?

* Mommy, was there a zeroth year? When was Jesus born?

Now let's see what would happen if we consistently counted everything from "zeroth", from seconds to millennia:

"The zeroth year of the second millennium begins at 2000/00/00 00:00:00."

Music to my mind.

Actually, when you think about it, one-based counting isn't even consistent with itself! If you have a bunch of pigs with two-digit labels painted on their sides, then the first pig among the first ten pigs will be labeled 01, so the word "first" means simultaneously 0 and 1. With zero-based counting, the zeroth pig among the zeroth ten pigs would be labeled 00, and all would be right with the world. Not to mention easier to program.

What do you think, HN? Am I on to something here?

1 comment

[ 3.5 ms ] story [ 7.3 ms ] thread
Zero = nothing. 00:00 is midnight and is neither PM nor AM.

The only reason we have stupid 0 based indexing in programming is for looping. Nothing important hangs on the things you are concerned about. Which millennium doesn't really matter if it is confusing it is consistent.