3 ms·
> Starting at 1 is more intuitive, and therefore IMO better. This is totally subjective. Starting at 0 is more intuitive to me. My intuition is very simple. `
by umanwizard 8y ago
> Starting at 1 is more intuitive, and therefore IMO better.
This is totally subjective. Starting at 0 is more intuitive to me.
My intuition is very simple. `x` is the name of some memory location. `x[k]` is the location `k` spaces away from `x`.
- throwawaymath 8y agoI can agree that's intuitive, but I'd like to point out that's not quite the same thing as numbering a sequence. If we have a sequence a_1, a_2, a3, ... we can talk about a_3 by calling it the third term. If we have a sequence a_0, a_1, a_2, ..., the third term is actually a_2. Whether or not we should index starting at 0 or 1 is probably dependent not only on intuition, but the application at hand. For most analytic purposes it's generally more useful to talk about the nth term, and we don't need to know a specific number to reason about the distance between any two indices. For other purposes, such as programmatic ones, it is useful to know e.g. the traversal distance between two items in a list. In my opinion it's best to first consider whether you're working in more of a mathematical or programmatic context, and then secondarily who will have to read it later on.
- umanwizard 8y agoYou don't have to talk about memory locations, or computers at all, for the intuition to work. `a_2` is two spaces away from the beginning of the list. The fact that our ordinal numbers are closely connected with the off-by-one cardinal numbers (e.g., "third", meaning the element of a sequence in position 2, is closely etymologically related to the word "three") is an unfortunate defect of language.
- notduncansmith 8y ago> we can talk about a_3 by calling it the third term It's still the "third" term. People commonly refer to the "zeroeth" term in a list as the "first" term, the "first" term as the "second", and so on. Admittedly, the usefulness of "zeroeth" depends on how often you think about the mechanics of array traversal, and that's probably not often if you don't program computers.
- zAy0LfpBZLC8mAC 8y agoIn other words: You noticed that array offset operations have an additive structure, and as the neutral element of addition is the zero, the only sane way to do indexing is to start at 0.
- tomtimtall 8y agoHaving reached introductionary programming to university studendts, I would say that it’s subjective for the individual but still generally true that 1-based indexing is more intuitive.