The initial classification started at 0. It’s right there in your link!
000 is not Computer science at all!
000 is Generalities that don’t fit anywhere else (bibliographies, encyclopedias, magazines, etc.). And that’s what it was back in 1876 too.
They had room in 000, computer science was a rising field, and it didn’t fit anywhere else neatly, so they put it there. And as it became more popular it was added to the header.
But 000 was there from day 1 half a century before the advent of computers.
The initial classification started at 0. It’s right there in your link!
Yep, ouch, that’s embarrassing. I saw “bibliography” and for some reason my mind switched off, ignoring the 0 and believing it was some sort of introduction. I’m deleting my message, since I already confused 6 users.
Building/Elevator numbering schemes, outside of the US, tend to use 0 based indexing.
The ground floor being 0 or G, the floor above ground being 1, floor below ground being -1 or B1.
I love that we’re doing that here, if for no other reason, to show people you can skin an elevator in many ways.
Foreigners who get thrown off by this aren’t totally wrong, because there’s no real reason for “our” way. Why wouldn’t ground be the first? To me it makes sense it’s special, but there are exceptions as well.
Multiple ground levels are a thing when a building’s by a hill or walking bridges. “P” can stand for parking or ground level over here.
The library example is much more objective, want more of those ;)
I once read the British translation of Murakami’s Kafka on the Shore, and it continually bugged me that they had translated it with 1st floor in the British sense. Japanese uses the same numbering scheme as America and the translator is American, so the Britishization of the floor numbering must have been done by the British editors as part of localization/localisation.
Well, no; centuries are numbered starting at 1, as are years. So, the first year ACE was year 1, which was in century 1. There are odd issues about how they relate to each other, and disputes as to when the century turns over, but those are unrelated to their indexing.
So 0 vs 1 indexing was a topic of early debate, and a lot of languages took a mulligan by making both possible. This is similar to how it is in math and physics. I checked a few different textbooks (QM, LinAlg, Alg, Analysis) and they all switch between 0 and 1 notation depending on which is more convenient. In particular, matrix operations are always 1-indexed, while polynomial and series-sums are almost always 0-indexed.
So by the early 1960’s, there are three different approaches to the data structure we now call an array.
Pointing out that Dijkstra regretted giving ALGOL 60 1-based indices does not refute Hoye’s claim. Whether they were 1-based or optional is splitting hairs. So far as I can tell, ISO 1538 doesn’t say one way or the other. Your third point about Lisp is a non sequitur. Hoye never claimed that Lisp was 1-indexed.
Hoye’s main point, which you have not addressed, is that C is the language that solidified the convention of using zero-based indexing, and that its progenitor, BCPL, established that convention to save compilation time on 1960s hardware. All the post-hoc rationalization that followed was just aestheticism in disguise. To quote Dijkstra from the same link you posted (emphasis mine):
Consider now the subsequences starting at the smallest natural number: inclusion of the upper bound would then force the latter to be unnatural by the time the sequence has shrunk to the empty one. That is ugly.
I’m personally inured, both to the clever, self-congratulatory tone in which zero-based indexing is taught and to the debate as a whole, but I’ll neither applaud this article nor defend Dijkstra’s aesthetics to the next generation of kids who tell me they also find taking the zeroth element of an array makes as much sense as taking the zeroth bus. Instead, I will try as patiently as I can to explain that, when learning a language, natural or programming, there are some conventions that are both counterintuitive and fixed by the age and practice of a rigid culture. One need not redefine ordinal numbers to the rest of the world in order to accept such quirks and move on.
Hoye’s main point, which you have not addressed, is that C is the language that solidified the convention of using zero-based indexing, and that its progenitor, BCPL, established that convention to save compilation time on 1960s hardware. All the post-hoc rationalization that followed was just aestheticism in disguise. To quote Dijkstra from the same link you posted (emphasis mine):
I’m not convinced that’s the whole explanation for why we settled on 0-based indexing — Dijkstra regretting 1-indexing shows that it isn’t a neat story of “it’s all BCPL”, there were parallel factors going on at the same time. And I’m certainly not convinced it’s just to save compilation time thing. Hoye literally got this quote from the inventor of BCPL:
Just as machine code allows address arithmetic so does BCPL, so if p is a pointer p+1 is a pointer to the next word after the one p points to. Naturally p+0 has the same value as p. The monodic indirection operator ! takes a pointer as it’s argument and returns the contents of the word pointed to. If v is a pointer !(v+I) will access the word pointed to by v+I. As I varies from zero upwards we access consecutive locations starting at the one pointed to by v when I is zero. […] I can see no sensible reason why the first element of a BCPL array should have subscript one. Note that 5!v is rather like a field selector accessing a field in a structure pointed to by v.
Richards never says that it was “to save compilation time on 1960s hardware”. All of his justification is aesthetic and “it matches the machines”. Hoye then says
the reason we started using zero-indexed arrays was because it shaved a couple of processor cycles off of a program’s compilation time
Without actually using anything in the Richards quote. If anything, he’s contradicting Richards: Hoye says that “*i = a + n*sizeof(x) is wrong” when Richards says that is, in fact, the reason he designed BCPL that way.
I’ll admit I’m pretty biased against the article as a whole, mostly because of this one line:
So if your answer started with “because in C…”, you’ve been repeating a good story you heard one time, without ever asking yourself if it’s true. It’s not about i = a + nsizeof(x) because pointers and structs didn’t exist. And that’s the most coherent argument I can find; there are dozens of other arguments for zero-indexing involving “natural numbers” or “elegance” or some other unresearched hippie voodoo nonsense that are either wrong or too dumb to rise to the level of wrong.
I think 0-indexing makes a lot of math more natural, guess I’m too dumb to rise to the level of wrong!
I have a feeling you haven’t read the whole thing. Hoye’s telling a story. Richards is only one character. He even anticipates your skepticism.
“Now just a second, Hoye”, I can hear you muttering. “I’ve looked at the BCPL manual and read Dr. Richards’ explanation and you’re not fooling anyone. That looks a lot like the efficient-pointer-arithmetic argument you were frothing about, except with exclamation points.”
I’ve read the whole thing, multiple times, first in 2015 or so.
“Now just a second, Hoye”, I can hear you muttering. “I’ve looked at the BCPL manual and read Dr. Richards’ explanation and you’re not fooling anyone. That looks a lot like the efficient-pointer-arithmetic argument you were frothing about, except with exclamation points.”
No, that doesn’t look like the efficient pointer arithmetic argument, because Richards says, multiple times, it’s about elegance of form and never once says it’s about efficiency.
Also notice that Hoye is in contact with Richards, but once he gets his thesis for why Richards started arrays at 0, he never goes back and asks him about it. Hoye isn’t doing any of the due diligence he needs to do!
This reminded me that Perl has a special variable, $[, that contains the starting index for arrays and string subscripts. It defaults to 0, but you can change it if the situation demands it.
In fact libraries do do something like this. The Dewey decimal system starts at 000, not 001.
[Comment removed by author]
The initial classification started at 0. It’s right there in your link!
000 is not Computer science at all! 000 is Generalities that don’t fit anywhere else (bibliographies, encyclopedias, magazines, etc.). And that’s what it was back in 1876 too.
They had room in 000, computer science was a rising field, and it didn’t fit anywhere else neatly, so they put it there. And as it became more popular it was added to the header.
But 000 was there from day 1 half a century before the advent of computers.
day 0 I guess?
Yep, ouch, that’s embarrassing. I saw “bibliography” and for some reason my mind switched off, ignoring the 0 and believing it was some sort of introduction. I’m deleting my message, since I already confused 6 users.
Well, thank you!
Building/Elevator numbering schemes, outside of the US, tend to use 0 based indexing.
The ground floor being 0 or G, the floor above ground being 1, floor below ground being -1 or B1.
I love that we’re doing that here, if for no other reason, to show people you can skin an elevator in many ways.
Foreigners who get thrown off by this aren’t totally wrong, because there’s no real reason for “our” way. Why wouldn’t ground be the first? To me it makes sense it’s special, but there are exceptions as well.
Multiple ground levels are a thing when a building’s by a hill or walking bridges. “P” can stand for parking or ground level over here.
The library example is much more objective, want more of those ;)
I once read the British translation of Murakami’s Kafka on the Shore, and it continually bugged me that they had translated it with 1st floor in the British sense. Japanese uses the same numbering scheme as America and the translator is American, so the Britishization of the floor numbering must have been done by the British editors as part of localization/localisation.
Centuries in the common era are another example. We’re currently in the twenty-first century, designated by dates starting with 20xx.
Well, no; centuries are numbered starting at 1, as are years. So, the first year ACE was year 1, which was in century 1. There are odd issues about how they relate to each other, and disputes as to when the century turns over, but those are unrelated to their indexing.
This is a variation on common post-hoc rationalization that’s been disproven.
I don’t find that convincing for three reasons:
So 0 vs 1 indexing was a topic of early debate, and a lot of languages took a mulligan by making both possible. This is similar to how it is in math and physics. I checked a few different textbooks (QM, LinAlg, Alg, Analysis) and they all switch between 0 and 1 notation depending on which is more convenient. In particular, matrix operations are always 1-indexed, while polynomial and series-sums are almost always 0-indexed.
Your claim and Mike Hoye’s are complimentary.
You:
Hoye:
Pointing out that Dijkstra regretted giving ALGOL 60 1-based indices does not refute Hoye’s claim. Whether they were 1-based or optional is splitting hairs. So far as I can tell, ISO 1538 doesn’t say one way or the other. Your third point about Lisp is a non sequitur. Hoye never claimed that Lisp was 1-indexed.
Hoye’s main point, which you have not addressed, is that C is the language that solidified the convention of using zero-based indexing, and that its progenitor, BCPL, established that convention to save compilation time on 1960s hardware. All the post-hoc rationalization that followed was just aestheticism in disguise. To quote Dijkstra from the same link you posted (emphasis mine):
I’m personally inured, both to the clever, self-congratulatory tone in which zero-based indexing is taught and to the debate as a whole, but I’ll neither applaud this article nor defend Dijkstra’s aesthetics to the next generation of kids who tell me they also find taking the zeroth element of an array makes as much sense as taking the zeroth bus. Instead, I will try as patiently as I can to explain that, when learning a language, natural or programming, there are some conventions that are both counterintuitive and fixed by the age and practice of a rigid culture. One need not redefine ordinal numbers to the rest of the world in order to accept such quirks and move on.
I’m not convinced that’s the whole explanation for why we settled on 0-based indexing — Dijkstra regretting 1-indexing shows that it isn’t a neat story of “it’s all BCPL”, there were parallel factors going on at the same time. And I’m certainly not convinced it’s just to save compilation time thing. Hoye literally got this quote from the inventor of BCPL:
Richards never says that it was “to save compilation time on 1960s hardware”. All of his justification is aesthetic and “it matches the machines”. Hoye then says
Without actually using anything in the Richards quote. If anything, he’s contradicting Richards: Hoye says that “
*i = a + n*sizeof(x)
is wrong” when Richards says that is, in fact, the reason he designed BCPL that way.I’ll admit I’m pretty biased against the article as a whole, mostly because of this one line:
I think 0-indexing makes a lot of math more natural, guess I’m too dumb to rise to the level of wrong!
I have a feeling you haven’t read the whole thing. Hoye’s telling a story. Richards is only one character. He even anticipates your skepticism.
Read on through the Tom Van Vleck correspondence.
I’ve read the whole thing, multiple times, first in 2015 or so.
No, that doesn’t look like the efficient pointer arithmetic argument, because Richards says, multiple times, it’s about elegance of form and never once says it’s about efficiency.
Also notice that Hoye is in contact with Richards, but once he gets his thesis for why Richards started arrays at 0, he never goes back and asks him about it. Hoye isn’t doing any of the due diligence he needs to do!
This reminded me that Perl has a special variable,
$[
, that contains the starting index for arrays and string subscripts. It defaults to 0, but you can change it if the situation demands it.cf. https://www.tutorialspoint.com/perl/perl_special_variables.htm
APL and Visual Basic Classic also have similar functionality; I consider it a misfeature.