[Python-ideas] List Revolution

Steven D'Aprano steve at pearwood.info
Sun Sep 11 02:37:21 CEST 2011


Guido van Rossum wrote:

> Plus pretty much every other language
> in widespread use today (C, C++, Java, C#, JavaScript, Ruby, to name a
> few; presumably also Objective C given its C inheritance) agrees that
> indexes start at zero. It is a cultural battle that  has been fought
> and won long ago (all the old languages used 1-based indexing:
> Fortran, Algol, Pascal)


Lua appears to be a conspicuous counter-example of a relatively recent 
popular language with 1-based indexing. See the (extremely incomplete!) 
list here:

http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(string_functions)

0-based indexes are useful for some tasks, and less useful for other 
tasks. In my experience, I find that 0-based indexing is more useful 
most of the time: it leads to fewer off-by-one errors.

1-based indexes are particularly well-suited for programming languages 
using a natural language metaphor, usually aimed at non-programmers. 
Examples include Xion, Applescript, and Inform-7.

The Ubiquity desktop appears to be aiming for a natural language 
scripting language, like Applescript only more so:

http://mitcho.com/blog/projects/how-natural-should-a-natural-interface-be/



-- 
Steven



More information about the Python-ideas mailing list