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

Liking zero indexed lists is such a dumb programmer meme. Lists are for humans to read and therefore should use the natural numbers, which start at one. Arrays are zero indexed because the first item of the array starts with zero offset.



>Lists are for humans to read and therefore should use the natural numbers

Depending on who you ask, the natural numbers do contain zero. Notably ISO 80000-2 is of that opinion. In university, half my professors included 0 in the natural numbers, half excluded it.

For lists, starting them at 1 makes sense, but I would argue that's purely because that way the words "first", "second", "fiftieth" etc. line up with the numbering. It has nothing to do with human consumption.

For example floor numbers are made for humans too, but the European scheme of labeling floors -2, -1, 0, 1, 2, 3 makes much more sense than leaving out 0, leading to awkward -2, -1, 1, 2, 3, 4. Years are made for humans too, but most people are confused about the ordering of years because having the year -1 followed by year 1 just seems weird and makes date math difficult (for humans).


To be fair to floor labels starting with 1, I have never seen a floor with a negative number.


You haven't been around much, then.

The seven-segment display inside the elevator in my former dormitory labelled the ground floor as '0', and the one below as '-1'. There was also a voice announcer, but I don't remember what it said on floor -1; I didn't go there often.


And it's because of dumb non-programmers that we have 12am immediately following 11pm. If we were to, instead, recognize the beginning/middle of the day as 0, the am/pm transitions would be sensible.

Starting at 0 is almost always correct, teaching people to start counting at 1 isn't. Why do we continually come up with convoluted workarounds simply because we educate children incorrectly?


I believe that hours going up to 12 instead of going 0 .. 11 is because you can't quite hear a bell strike zero times, no?


Although that's kind of a clever response, most bells have a chime to alert you to the hour change so it would just be the chime without the counted bell strikes. Better yet, since 0 would always be the start of a new day, make the strikes do some kind of awesome song.


Wat? There are 24 hours in a day 1-24 or 0-23, pick your poison. But 100% Fuck halfday, 1-12 bullshit.

P.S. Also fuckoff non-UTC time.


I wish we could all schedule things on UTC time. I've been part of 10 person meetings across 4 time zones and scheduling sucks. Inevitably someone assumes a meeting is scheduled in their local time.


You don't have to be in UTC, but having your clock set to 24 hours still makes it a lot easier.

After a year of daily meetings with people on the east coast (of the US), London, Hamberg, and Brasilia from the west coast of the US I just moved to 24 hours and found it much easier to mentally calculate everyone's respective times- as long as I could keep the offsets squared away.

Screw daylight savings.


It's even worse when you don't observe DST but basically everyone else does.

I can't even keep the offsets squared away since they shift a couple times a year.


Fuck hours. There's only 1440 minutes a day. No time for hour conversions.


> Lists are for humans to read and therefore should use the natural numbers, which start at one.

https://en.wikipedia.org/wiki/Peano_axioms#Formulation

To address the content of your post: I agree, but humans aren't purely logical devices created by Dr. Noonien Soong, and we do enjoy playing with things and joking about.


Peano axioms can just as well be formulated with 1 as the smallest natural number, with little consequence as to the expressiveness of the resulting theory.

Not that there aren't mathematical reasons to start counting with zero, but this isn't a very strong one, at least not without further elaboration.


Since we're picking all the nits and talking about definitions like the natural numbers rather than common parlance, then may I observe that sequential lists are using ordinal numbers, and the set of ordinals derived from natural numbers definitely does start with zero, in this case it being the minimum element of the ordinals of non-zero cardinality.


Hours go 0:00 to 23:59

Elevators use 0 for ground floor, negative for basements, and positive for upper floors.

Just two examples of zero indexed lists in real life.


And sometimes to 23:60.


I found it interesting to see that building floors in Australia are zero indexed. The first floor there is what Americans would call the second. Not sure why they chose to do it that way but it works fine in the real world.


That's not the case in all Australian buildings. Usually we call the ground floor "ground floor" (which you could argue is 0-indexed), and the floor above it is "the first floor". But there are a lot of buildings that follow the American style of "the ground floor is the first floor".

We also don't use negative numbers, basements are prefixed with a B, so B1 is like -1.


Due to hills, many of the buildings at my American university were 2 indexed: Due to hills, the apparent ground floor was usually labeled "2nd Floor".


The U.K. does the same. Starts with ground floor, then first


Ever been in an elevator in Europe?


My recollection is that arrays are zero indexed because time shared compilers were too slow to do the arithmetic shift in the compilation phase. I can't find a good citation offhand though.


Oh, thanks for deciding that for us.


I like it even more now.




Consider applying for YC's W25 batch! Applications are open till Nov 12.

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

Search: