4 ms·
Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion. I have my opinion, and that is
by Bromskloss 9y ago
Which one is "right" and which one is "wrong" (those are strong words I chose somewhat tongue-in-cheek) is a matter of opinion.
I have my opinion, and that is that zero is the proper number to start enumerations on, not just in programming, but for everything.
- goatlover 9y agoSure, but why would zero be the proper number to start counting at outside of zero-based programming languages? Everyone starts counting objects at 1. Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number. Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages, although maybe there are some mathematicians who think otherwise?
- Bromskloss 9y ago> Sure, but why would zero be the proper number to start counting at outside of zero-based programming languages? I don't take programming languages as a reference point. It's the other way around. I try to figure out what the most natural, principled, and elegant way would be, and I would base my programming language on that, if I were to design one. > Zero means an absence of objects to count or list. I count that there are 7 cars in the lot. The first one is 1. If there were 0 cars, I would not have any to enumerate over. If I make a list, I always number the first one as 1 (or A). If there was nothing on my list, I would have nothing (0) to number. We should distinguish between two uses of the natural numbers, I think: 0. _Ordinal numbers_, for assigning labels to things. "This is car 3." 1. _Cardinal numbers_, for saying how many things there are. "There are 7 cars." The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars. > Word processors start list numbering at 1. Printers number the first page as 1. Kids are taught to count starting with one, using one finger. I feel like this is only an argument because we have zero-based indexing in mainstream programming languages What is the most common isn't what determines, for me, what is the most proper. I will play along and use 1-based indexing when I have too, but in my heart I know how I think it should _really_ be. > maybe there are some mathematicians who think otherwise? Yes, though starting numberings on 1 is still common (maybe the most common). Zero is at least recognised as a natural number nowadays. Historically, this wasn't the case. Apparently, Peano started on 1 in his axioms for the natural numbers [0], and zero, as far as I understand, hardly had the status of being a number at all during much of Greek and Roman antiquity [1]. [0] https://en.wikipedia.org/wiki/Peano_axioms#Formulation https://en.wikipedia.org/wiki/Peano_axioms#Formulation [1] https://en.wikipedia.org/wiki/0#Classical_antiquity https://en.wikipedia.org/wiki/0#Classical_antiquity
- goatlover 9y ago> The relationship between the two would be that the number of cars is the number that is next in line when you have called out the indices (0, 1, 2, 3, 4, 5, 6) of all the cars. But who thinks that way? I just see 7 cars, not an indexed listing. And anyway, the 0 indexed car doesn't exist.
- Bromskloss 9y agoHe who finds zero-based indexing to be the proper way and wants to shape his thinking thereafter!
- rrock 9y agoNo, zero is the right number to start an offset, not an enumeration. No one starts counting from zero in real life.
- Bromskloss 9y ago> No one starts counting from zero in real life. The question for me is what one _should_ do, not what is usually done.