3 ms·
Normally education or human oriented languages start arrays at 1 (Smalltalk, Cobol, Lua, APL, Wolfram, etc) while hardware oriented languages start arrays at 0
by jecel 3y ago
Normally education or human oriented languages start arrays at 1 (Smalltalk, Cobol, Lua, APL, Wolfram, etc) while hardware oriented languages start arrays at 0 (C and friends, Oberon, Forth, Scheme and so on). Human oriented languages that have to play nice with C also tend to use 0. As do Python and Basic, which contradicts my rule.
Probably the number one reason not to start arrays at 0 in an educational language is that having the last element of an array of size 10 have an index of 9 causes quite a bit of confusion.