Explain xkcd: It's 'cause you're dumb.
Donald Knuth is a computer science Professor Emeritus at Stanford University who is famous for writing The Art of Computer Programming and developing the TeX computerized typesetting system.
An "array" in computer science is a structure that holds multiple values, and is "indexed" by a number. In Pascal, for instance, one writes array to access the first element in the array. Most "modern" (read: descended from C) languages use 0 as the index for the first element in the array, but it is possible (if one is careful about it) to ignore the 0th element and use 1 as the first index. Cueball is complaining that Black Hat was not consistent in his choice of where to start his arrays.
Black Hat's citation of Donald Knuth implies that he broke into the professors house in the middle of the night, and has nothing to do with the argument over array indexes.
- [Two programmers, Black Hat and Cueball are sitting back to back at two separate desks, typing.]
- Cueball: Man, you're being inconsistent with your array indices. Some are from one, some are from zero.
- Black Hat: Different tasks call for different conventions. To quote Stanford algorithm's expert Donald Knuth, "Who are you? How did you get in my house?"
- Cueball: Wait, what?
- Black Hat: Well, that's what he said when I asked him about it.
add a comment! ⋅ add a topic (use sparingly)! ⋅ refresh comments!
In Pascal you define the lower and upper bounds of an array when you declare it, e.g.,
anArray[-5 .. 5] OF integer
which has always struck me as a much better idea than having arrays always starting at 0.
Jstout (talk) 20:41, 18 February 2014 (UTC)
Why the swipe at Ada? I don't know about "the programming language of the future", but it's not a historical footnote either. It's used in many safety critical systems such as flight control, trains, even banking, and not just because that's what was used in the past. This language is still heavily used in these areas and is still being updated under MIL-STD and ISO.--220.127.116.11 15:33, 18 January 2015 (UTC)
- Wikipedia verifies your claims. Removed. Suspender guy (talk) 20:28, 9 October 2015 (UTC)
- Same is true of BASIC; you can specify any range, including negative numbers (I have used this). I program in C as well though --18.104.22.168 03:29, 24 December 2015 (UTC)