Comment

Comment by zAy0LfpBZLC8mAC

> But having L[2] be the third index in an array is horribly counterintuitive and leads to countless mistakes.

Really, that's just a confusion caused by language and historical accidents.

There is nothing that inherently links "one" to "first", or "two" to "second"--it just so happens that for some weird reason, it's common in English to abbreviate "first" as "1st", "second" as "2nd", and so on.

But just as "A" is the first letter of the alphabet (and not, say, the Ast), "0" is the first cardinal number, and "first" is the first ordinal number.

And there is a very simple reason why zero is the correct default first array index: Zero is the neutral element of addition, and (sub)array indexing is an additive operation.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton