From: Robert Dober Date: 2007-07-17T15:10:15+09:00 Subject: Re: The Pebble in the Ruby Shoe On 7/17/07, Frank Church wrote: > On 16/07/07, Raphael Gillett wrote: > > > > > > Ruby aims to be a human friendly programming language that embodies the > > principle of least surprise. However, there is an important feature of > > the language that, despite being a glaring exception to this laudable > > goal, seems to have crept unquestioned into the Ruby core. It is a > > rebarbative and truly medieval practice which everyone knows causes > > endless confusion, countless unnecessary errors, and a great deal of > > wasted programming time in all languages that incorporate it, e.g., C, > > Java. In violation of Ruby's ethos, this feature is present purely to > > suit the compiler/interpreter at the expense of the person. > > > > 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. Like prisoners who have got used to their chains, the > > Ruby community seems to have meekly accepted this impediment to clear > > thinking. It is particularly puzzling that Ruby should hobble its > > users in this way, because it is manifestly unnecessary (e.g., Fortran > > and Pascal don't do it). > > > > -- > > Posted via http://www.ruby-forum.com/. > > > > > > Is this some kind of troll? Possibly, however... > > My own experience with programming makes me feel that counting arrays > from 0 is the natural thing. If you are handling an array 5 items > starting from x, going from x+0 to x+4 is more concise than going from > x+1-1 to x+5-1. There are other examples in which I have found it > convenient. So is mine, but here eventually ;) my Ada background comes in handy, we are used to declaring our own bounderies. I believe that all is habit, but being used to 0 makes life easier I believe. We could also argue about the values #times is yielding, right;) > > Chinese count birthdays starting with the child's first year as year > 1. As a westerner do you consider it natural describe a child as 2 > years old on its "first" birthday? You see, all habit, and it shows some intellectual short sight to dismiss ideas foreign to our paradigm -- that's why I am doing it all the time ;). > > It may be counterintuitive but in the mathematical world it is quite natural. Or maybe common would be a better world; In Austria where I went to school 0 is not a positive number. In France I am constantly confronted with the notation that a whole number is either positive or negative defining 0 of being part of the former, drives me crazy, but makes lots of texts much shorter -- they seem never to use natural number for positive including 0. But maybe some learned francophone mathematician can mail me off list, I am only working with engineers, natural as an engineer, you know ;) Cheers Robert > > -- I always knew that one day Smalltalk would replace Java. I just didn't know it would be called Ruby -- Kent Beck