Wednesday, October 30, 2013

Why Array Indices Start at Zero

Mike Hoye:

This is interesting for a number of reasons, though I’ll leave their enumeration to your discretion. The one that I find most striking, though, is that this is the earliest example I can find of the understanding that a programming language is a user interface, and that there are difficult, subtle tradeoffs to make between resources and usability. Remember, all this was at a time when everything about the future of human-computer interaction was up in the air, from the shape of the keyboard and the glyphs on the switches and keycaps right down to how the ones and zeros were manifested in paper ribbon and bare metal; this note by the late Dennis Ritchie might give you a taste of the situation, where he mentions that five years later one of the primary reasons they went with C’s square-bracket array notation was that it was getting steadily easier to reliably find square brackets on the world’s keyboards.

Update (2013-10-31): Guido van Rossum:

I recall thinking about it a lot; ABC, one of Python’s predecessors, used 1-based indexing, while C, the other big influence, used 0-based. My first few programming languages (Algol, Fortran, Pascal) used 1-based or variable-based. I think that one of the issues that helped me decide was slice notation.

Update (2013-11-22): There’s an interesting discussion on Lambda the Ultimate.

1 Comment RSS · Twitter

[…] Why Array Indices Start at Zero. I find Hoye’s post interesting but not entirely […]

Leave a Comment