Thats great stuff, Ben.

Specially the "Ruby is supposed to be easy for the programmer, not for 
the interpreter." is a great point, alone.

Nice one !


Cheers,


Rove Monteux

Ben Giddings wrote:

> On Jan 22, 2004, at 05:50, GGarramuno wrote:
>
>> That is indeed interesting!   My idea that for loops were faster were
>> taken from some ruby online docs stating that as one of the
>> optimizations to do.  I guess that was true of ruby1.6, perhaps.  Or
>> the author was just talking about arrays, only.
>> If I turn the range into an array, the iteration itself is faster,
>> thou.
>> It seems for in and by itself is now slow in ruby1.8.1.  And an even
>> bigger surprise is to find that a while loop performs the slowest
>> (almost twice as slow now!!!), when it is the one that is not
>> constructing anything but an integer.  Hmm...
>> On the positive side, I guess this means there's still quite some room
>> for optimizing these on a future ruby version.
>
>
> Overall, I think it's more Matz' philosophy that you shouldn't write 
> your Ruby code based on how you think the Ruby interpreter will 
> perform, but rather what seems most natural. 
>
> Aside from that, there's the philosophy of "don't optimize code too 
> soon".  If a given loop is a problem when you're done -- then you can 
> figure out how to speed things up at that point.   Choosing a less 
> intuitive loop construct because you have read it might be faster is 
> probably a mistake from a maintenance and readability point of view, 
> even if at this moment, it may be faster.
>
> Ben
>
>
>
>

-- 
Rove Monteux
Systems Administrator

rove.monteux / fluid-rock.com