Once again, here’s the transcript (and feel free to use the image above as well):
I’m not questioning your teaching abilities, but that apparently (from tone) you dislike the idea of indexing from 0.
This is unfortunately not uncommon (see the lua language, for example) but the fact remains that indexing from 1 is a bad idea and EWD was right on this.
Sometimes it helps thinking to indexes as being “between” elements…
[Insert image of “Hello, World” with the indices labeled]
so the interval 3-5 is clearly “lo” and the number of elements included in the interval a, b is b – a.
This way of thinking simplifies a lot reasoning for example when implementing binary search or raster graphics algorithms.
This mental model is equivalent to [a, b[ , but (maybe) easier to understand and remember.
x[i] is just the element between i and i+1.
Some API solve the problem of substring-like interfaces by relying on start/size instead of start/end (this is what Qt does in many cases, for example). Unfortunately the same Qt framework made the wrong choice of using “boundary-inclusive” intervals when implementing right() and bottom() method for integer rectangles, a poor choice that makes hard to write pixel-perfect code and force a lot of +1 and -1 in code: floating point rectangles are ok, and they mistake on the integer case is acknowledged in the documentation (but unfortunately cannot be removed because of backward compatibility reasons).
To me, this was one of the weirdest responses I’ve ever gotten. After all, not only was this person arguing against a strawman (i.e. I never once said I didn’t like indexing by 0), he also felt the need to “educate” me on something I clearly already understood. It was so very weird.
After the second giant comment from this guy, I felt the need to ask him: “what is your end goal here?” For real though, what was his end goal?