3 ms·
Nobody says that a baby is 0 years old. They use other words instead of numbers, or if they do use a number, it is X hours / days / weeks / months old. 0 in no
by zdragnar 4y ago
Nobody says that a baby is 0 years old. They use other words instead of numbers, or if they do use a number, it is X hours / days / weeks / months old.
0 in normal usage is always a negation of something existing. You don't start counting things that exist at 0 (as you pointed out in your example of number of red balls in a bag that have none). However, position zero at an array in zero-indexed languages is the first position within the array.
There's no getting around the fact that higher level languages inherited 0 by counting byte offsets, rather than positions, even if those languages don't required that every index within an array have the same size in memory (or occupy a contiguous block of memory), and that this inherited usage is at odds with the actual plain-language and true meaning.
- mfost 4y agoOf course they don't. They use decimals and say the baby is one week old or so. As for indexing from zero, it's best understood as indexing the position just before elements in an array. Where things will be inserted if you insert an element etc...
- zdragnar 4y agoSo, to use some pseudocode: var item = my_array[2] should be read as "assign to item the value in my_array in the position where you would place something new just before the third item" 1-indexing is, strictly speaking, a better design. The only real argument for it anymore in a higher level language is "it's what I'm used to", or alternatively, "0 already won the popularity contest" (which is actually not a terrible argument in context, though it is a bad one from a purely objective design perspective).
- mfost 4y agoSaying it's strictly better is exaggerated. The benefits of 0 indexing are well known and mostly revolve around the fact you tend to have far less fiddling with -1 and +1 as you write code. How do you access the item in a 2D array represented on a flat array? my_array[x+ywidth] But what is all that starts at 1? my_array[x+(y-1)width] I did a lot of code in both systems and I remember distinctly that 1.. indexing just was more work to do, in turn bringing in more off by 1 bugs.
- pmelendez 4y ago>The benefits of 0 indexing are well known and mostly revolve around the fact you tend to have far less fiddling with -1 and +1 as you write code. Depends on what you are doing. I seldom have to do a flat 2D array these days, but array[total-1] is an almost everyday thing.
- chalst 4y agoDijkstra's arguments [1] about the benefits of 0-indexing are about tricky edge cases when coding with arrays. (The example you give is not a correctness problem, but a memory-efficiency issue: if width=1, you'll not be using at least half of the structure's indices that you allocated). But Lua doesn't have arrays as a type, it only has a way of iterating over the array part of tables, its map data structure. Idiomatic Lua code for tables doesn't run into the kind of edge cases Dijkstra presents, since the most readable code uses iterators to yield the values of array indices when one wants to access the array part of tables. It makes perfect sense to add arrays as a userdata type. For these, there are benefits of 0-indexing, as seen in https://github.com/neomantra/lds https://github.com/neomantra/lds - although mixing 0-indexed [1]: https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/E...
- m463 4y ago1/52 of a year 3/12 of a year even after a year, they might say 18/12 of a year.
- ordiel 4y agoYou start your argument with a missconception, 0 does not relates to the existance of something but rather the lack of. When a bank acount reaches 0 it does not mean money does not exist, neither it means the account does not exist, it just means there are no units there of that you are counting...
- memco 4y ago> Nobody says that a baby is 0 years old. Totally irrelevant to the the actual conversation but I have in fact put my infant child’s age as 0 because I didn’t think to count in smaller increments than years. So there is at least one person who says babies are 0 years old.
- thunky 4y ago> Nobody says that a baby is 0 years old That's only because age can easily be measured and described in units smaller than whole years, while array indexes can't be divided.