5 ms·
1-based numbering is nonsense. How many years old are you when you’re born? I notice almost all defenses of 1-based indexing are purely based on arbitrary cult
by School-Cotton 2y ago
1-based numbering is nonsense. How many years old are you when you’re born?
I notice almost all defenses of 1-based indexing are purely based on arbitrary cultural factors or historical conventions, e.g. “that’s how it’s done in math”, rather than logical arguments.
- Ukv 2y ago> How many years old are you when you’re born? You have lived zero full years and are in the first year of your life. In most (but not all) countries the former is considered "your age". That's consistent with both zero-based and one-based indexing. Both agree on cardinal numbers (an array [1, 2] has length 2), just not on ordinal numbers (whether the 1 in that array is the "first" or "zeroth" element). > I notice almost all defenses of 1-based indexing are purely based on arbitrary cultural factors or historical conventions, e.g. “that’s how it’s done in math”, rather than logical arguments. I think it's largely a matter of taste in either direction. But, I'd raise this challenge: arr = ['A', 'B', 'C', 'D', 'E', 'F'] slice = arr[3:1:-1] print(slice) If you're unfamiliar with Python (zero-based, half-open ranges exclusive of end), that's taking a slice from index 3 to index 1, backwards (step -1). How quickly can you intuit what it'll print? Personally I feel like I have to go through a few steps of reasoning to reach the right answer - even despite having almost exclusively used languages with 0-based indexing. If Python were instead to use MatLab-style indexing (one-based, inclusive ranges), I could immediately say ['C', 'B', 'A'].
- School-Cotton 2y agoI don’t know python but I figured out immediately that it should print ['C', 'B']. Does it? If not, Python is just wrong.
- pansa2 2y agoNo, it doesn't, it prints ['D', 'C']. I agree that it should be ['C', 'B'] - the way that Python handles negative `step` values is wrong.
- Ukv 2y agoI don't think it's "wrong" per se - it's zero-based indexing and ranges are consistently inclusive of start, exclusive of end. But, it breaks the "fence-post" mental model that some people use, and is less intuitive than MatLab's indexing approach IMO.
- pansa2 2y ago> I don't think it's "wrong" per se I do. I think it only makes sense for ranges to be inclusive at the lower end and exclusive at the higher end. A slice with a negative step `-n` should contain the same elements as the same slice as with step `n`, just reversed.
- weinzierl 2y agoBoth agree on cardinal numbers (an array [1, 2] has length 2), just not on ordinal numbers (whether the 1 in that array is the "first" or "zeroth" element). I think whenever people say "zeroth" they speak in jest and doubt that there is any disagreement on the fact that the element without predecessor (nowadays in programming most often assigned index 0) is the first element. You used "first" in that sense naturally just in the sentence before without the slightest notion of ambiguity. You have lived zero full years and are in the first year of your life. What people wrongly get riled up with is the fact that ordinal (first) is not in sync with the cardinal (index 0), but it rarely is anyways. If you go to an administrative office and pull your number 5357 no one assumes that there are 5356 people in the queue before them. Your are still the 5th or 10th in line, even if your index is 5357.
- Ukv 2y ago> I think whenever people say "zeroth" they speak in jest and doubt that there is any disagreement on the fact that the element without predecessor (nowadays in programming most often assigned index 0) is the first element. "Zeroth" sounds silly because English has generally settled on one-based indexing, and so typically you'd convert to one-based indexing when speaking out loud or writing something other than code (`users[3]` is the "4th user"). Maybe you could argue that the words "first"/"second", as just some letters/sounds, are not inherently one-based? But I feel that gets a bit dubious from "third" onwards where the connection to numbers is obvious, and with the ordinals frequently spelled as 1st/2nd/etc. But, if you want (and if I'm understanding what you mean), you could replace my statement with: "whether the '1' in that array is the index-1 or index-0 element" - purpose was just to distinguish between ordinals and cardinals, in response to a comment that seemingly implied the cardinality of an empty collection would be 1 with one-based-indexing.
- nkrisc 2y ago> 1-based numbering is nonsense. How many years old are you when you’re born? Typically 3 months shy of 1 year, so about 0.75.
- amiga386 2y agoThe key word in "birthday" is "birth". Not conception. For human cultural purposes, you are 0 days old at the time and date recorded for your birth. It goes on your birth certificate. If you find a culture that celebrates conceptiondays and issues conception certificates, let me know.
- dagw 2y agoFor human cultural purposes, you are 0 days old at the time and date recorded for your birth While that is the norm, there both are and have been cultures where you are 1 when you are born (as in you are living your first year of life).
- nkrisc 2y agoThe comment I’m replying said nothing about “birthday”. They asked how many years old you are when you’re born, which is ambiguous. You know some cultures don’t even celebrate birthdays, right? It’s not even uncommon for people to not know their date of birth. Even my own grandmother, born in Chicago in the 1920s, didn’t even know exactly what year she was born in.
- amiga386 2y agoWhen you're born. That is your birth day, because the person to whom you were born gave birth to you that day. No culture I know of tracks the date of your conception as a measure of your age. If they measure it at all, the starting point is your birth. You are zero days old on the day of your birth. Even if those cultures think you are "in the first year of your birth" for days 0-365 of your existence, they would accept that 1 day after your birth, you are 1 day old, not 9 months old.
- hans_castorp 2y agoSo if you go into a bar and order a beer, you drink the zeroth beer before the first?
- School-Cotton 2y agoYou would, if English were logical as opposed to being a randomly-evolved cultural practice. With computer languages we have the opportunity to fix the mistakes of the past and do better.
- deleted 2y ago[deleted]
- pasc1878 2y agoWhen I was doing actuarial work all ages were age next birthday. So you start at age 1!
- Y_Y 2y ago> How many years old are you when you’re born? Consider the following from the Irish Constitution: > 12.4.1° Gach saoránach ag a bhfuil cúig bliana tríochad slán, is intofa chun oifig an Uachtaráin é. and the official translation to English: > 12.4.1° Every citizen who has reached his thirty-fifth year of age is eligible for election to the office of President. For those unfortunate few who do not understand Irish, that version says "Every citizen who is at least thirty-five years old", whereas the translation should in principle (arguably) allow a thirty-four-year-old. Luckily the Irish version takes precedence legally. A constitutional amendment which would have lowered the minimum age to 21 and resolved the discrepancy was inexplicably rejected by the electorate in 2015.
- personalityson 2y agoAnother idiot confusing continuous measure (time) with counting discrete units If it helps: you have one whole array element only if one year has passed What are you trying to do: do you want to know where each element starts, or do you want to measure the total sum/accumulated amount?