Dijkstra on Array Index

By Xah Lee. Date: .

Dijkstra on Array Index

The computer scientist Edsger W Dijkstra (EWD) thinks it should start at 0.

Dijkstra on Array Index 2025-08-02 25f21
Dijkstra on Array Index 2025-08-02 25f21

But it's not really convincing.

(1) Dijkstra gave his reasons about how a range function from A to B of integers, should include A and exclude B. For example, he'd have range(2,5) return [2,3,4].

The reason he prefer that because:

(2) he then gave his reasons that a index function to extract a array, should start at 0. That is, myArray[0] returns the first element in the array. Dijkstra thinks this is consistent with his (1).