So to be clear, we have to tediously specify "z e r o - b a s e d " or "o n e - b a s e d" every single time to avoid confusion. (Is there a chance for creating some new, terser consensus here?)
Numbering should start at zero (1982)
11–20 of 309 posts
Re: Numbering should start at zero (1982)
#12Re: Numbering should start at zero (1982)
#13I found it devastating that there are no distinct agreed-upon words denoting zero- and one-based addressing. Initially I thought that the word "index" clearly denotes zero-base, and for one-base there is "order", "position", "rank" or some other word, but after rather painful and humiliating research I stood corrected. ("Index" is really used in both meanings, and without prior knowledge of the context, there is real…
Re: Numbering should start at zero (1982)
#14The 1980s were not a particularly enlightened time for programming language design; and Dijkstra's opinions seem to carry extra weight mainly because his name has a certain shock and awe factor. It isn't usual for me to agree with the mathematical convention for notations, but the 1st element of a sequence being denoted with a "1" just seems obviously superior. I'm sure there is a culture that counts their first fing…
Re: Numbering should start at zero (1982)
#15I found it devastating that there are no distinct agreed-upon words denoting zero- and one-based addressing. Initially I thought that the word "index" clearly denotes zero-base, and for one-base there is "order", "position", "rank" or some other word, but after rather painful and humiliating research I stood corrected. ("Index" is really used in both meanings, and without prior knowledge of the context, there is real…
I can suggest "z8d" and "o7d" otherwise. (/jk)
Re: Numbering should start at zero (1982)
#16The 1980s were not a particularly enlightened time for programming language design; and Dijkstra's opinions seem to carry extra weight mainly because his name has a certain shock and awe factor. It isn't usual for me to agree with the mathematical convention for notations, but the 1st element of a sequence being denoted with a "1" just seems obviously superior. I'm sure there is a culture that counts their first fing…
Zero-based counting works better with modular arithmetic. Like arr[(i++ % arr.length)] = foo; Is certainly nicer than the equivalent in one-based subscripting arr[(i++ % arr.length) + 1] = foo; (The above is actually wrong, which helps the idea) I'll concede that it's not all that significant as a difference, but at least IMO it's nicer. Also could argue that modular arithmetic and zero-based indexing makes more sens…
last := vector[vector-length(vector)];
is nicer than last := vector[vector-length(vector) - 1];
so in the end I'd say 'de gustibus non est disputandum' and people who prefer 0-based indexing can use most languages and I can dream of my own.Re: Numbering should start at zero (1982)
#17Languages aimed at casual audiences (e.g. scripting languages like Lua) should maybe just provide two different ways of indexing into arrays: an `offset` method that's zero-indexed, and an `item` method that's one-indexed. Let users pick, in a way that's mildly less confusing than languages that let you override the behavior of the indexing operator (an operator which really doesn't particularly need to exist in a world where iterators are commonplace).
Re: Numbering should start at zero (1982)
#181 or 0-based index... I recently picked up Lua for a toy project and I got to say that decades of training with 0-based indexes makes it hard for me to write correct lua code on the first try. I suppose 1-based index is more logical, but decades of programming languages choosing 0-based index is hard to ignore.
Re: Numbering should start at zero (1982)
#191 or 0-based index... I recently picked up Lua for a toy project and I got to say that decades of training with 0-based indexes makes it hard for me to write correct lua code on the first try. I suppose 1-based index is more logical, but decades of programming languages choosing 0-based index is hard to ignore.