this post was submitted on 19 Sep 2024
1463 points (98.5% liked)
Programmer Humor
32410 readers
182 users here now
Post funny things about programming here! (Or just rant about your favourite programming language.)
Rules:
- Posts must be relevant to programming, programmers, or computer science.
- No NSFW content.
- Jokes must be in good taste. No hate speech, bigotry, etc.
founded 5 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Most humans wouldd never write the word
first
followed by()
. It absolutely should have beenzeroth()
, and would not cause any confusion amongst anyone who needed to write it.It absolutely should not have been named zeroth() because the reasoning for that is purely pedantic and ignores WHY arrays are 0 indexed. It's not like the people in the early days of writing programming languages were saying "the zeroth item in the array" - they would refer to it using human language because they are humans, not machines. Arrays are 0 indexed because it's more efficient for address location. To get the location in memory of an array item, it's startingAddress + (objectSize * index). If they were 1 indexed, the machine would have to reverse the offset.
Function/Method names, on the other hand, should be written so as to make the most sense to the humans reading and writing the code, because the humans are the only ones that care what the name is. When you have an array or list, it's intuitive to think "I want the first thing in the array" or "I want the last thing in the array)," so it makes sense to use first and last. That also makes them intuitive counterparts (what would be the intuitive counterpart to "zeroth"?).
My argument is purely pedantic. Pedantry is the lifeblood of programmer "humour".
I'm not arguing that we should adopt zero-based numberingin real-life human applications. I am arguing that in zero-based numbering, the label "zeroth" refers to the same ordinal as "first" in one-based numbering. I am poking fun at the conversion between human one-based numbering and computers' zero-based numbering. That is why I am saying it should be called
zeroth()
; because human language should adapt to match the zero-based numbering their tools use. Whether I actually mean what I say—well, I leave that up to you.It does not matter why indexes start from zero in computing. The memory offset argument is only salient if you are using it as an argument for why computers should use zero-based numbering. It is not an argument against the properties of zero-based numbering itself.
Of course—that’s why we have such classics as
stristr()
,strpbrk()
, andstripos()
. Pretty obvious what the differences are there.But to your point, the ‘intuitive’ counterpart to ‘zeroth’ is the item with index zero. What we have is a mishmash of accurate and colloquial terms for the same thing.
explode('brain', 'ai')