From: Chad Perrin Date: 2007-07-19T05:23:48+09:00 Subject: Re: The Pebble in the Ruby Shoe On Thu, Jul 19, 2007 at 02:10:08AM +0900, John W. Kennedy wrote: > kevin cline wrote: > >On Jul 16, 8:22 am, Raphael Gillett > >wrote: > >>Ruby aims to be a human friendly programming language that embodies the > >>principle of least surprise... > > > >>The pebble in the Ruby shoe is the counter-intuitive use of indexing of > >>elements of arrays, strings, etc., from 0 to n-1 instead of the more > >>natural 1 to n. > > > >With 50+ years of collective experience, it seems clear that zero- > >based arrays lead to the simplest code. > > ...unless there is a lot of exposure of nominal index values to the end > user, in which case the additional effort of doing that may incur more > complexity than is saved by using 0-origin internally. Not always true. Think of voting systems, such as on reddit, where the positive value of something is the sum of all the increment-votes and decrement-votes assigned to it. The index value in a zero-based array would be exactly what you'd want to expose to the end-user in such a circumstance. Of course, such systems aren't always (or even usually, perhaps) managed with an array -- but when you're trying to keep track of who up- or down-voted something, as well as how many votes it got, an array starts to look more interesting. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] Dr. Ron Paul: "Liberty has meaning only if we still believe in it when terrible things happen and a false government security blanket beckons."