Counting from zero
cesare at poeticstudios.com
Mon May 1 20:33:18 UTC 2006
Tom Phoenix wrote:
> On 5/1/06, Laurence Rozier <laurence.rozier at gmail.com> wrote:
>> So true. The admonition "remember arrays start at zero" is repeated
>> countless times in most literature. You see this in just about every
>> article or book on most modern languages. If it were so "natural" to
>> count groups of things from 0 people wouldn't need to be reminded
> You're right; it's not natural to count from zero. All those people
> who used Roman numerals and similar systems before about the year 600
> never thought of it once. It took hundreds more years for the zero to
> be in common use; many people simply didn't accept it as a number.
> But even then, if they had wished to measured a distance, what number
> would have marked the beginning of their measuring tape? If they had
> thought to measure time, what number would represent the beginning of
> their measurements? How did their census takers report a home without
> Although it's not necessarily natural to count from zero, there are
> good reasons to teach when, why, and how to count from zero.
> --Tom Phoenix
Tom, your argument is a little misleading to me. You can use 0 as a
number wherever you want in Smalltalk. So you can use zero to mark the
beginning of a tape and to report the result of a census for a family
An array should be use to store a collection of things (any of its
values can contain zero even in Smalltalk). And calling the first
element of an array 1 does make much more sense.
Most lower level programming languages start counting from 0 (for
arrays) just because they're nearer to machine language and thus to the
hardware. Smalltalk isn't anyway.
More information about the Squeak-dev