botp wrote in post #1067101:
> #ruby2.rb
> i=0
> while i <= 10_000_000
>   i += 1
> end
>
> puts i
>
> #perl1.pl
> #Perl:
> for my $n ( 0 .. 1e7 - 1) {
>    $i ++
> }

This is a slight cheat, since my examples had addition independent of 
loop control.  But nevertheless if I do the following:

i, j = 0,0
while j < 10_000_000
  i+=1
  j+=1
end
puts "i = #{i}"

Then the Perl and Ruby are very close in speed (versions 5.10, 1.9), 
which was non-obvious to me, since on the face of it,

10_000_000.times { i += 1 }

seems cleaner (seems the details are in how the block is invoked in each 
case).

It makes me wonder if there's room for a more efficient looping 
construct, since a while-loop is clumsy.  But perhaps performance is an 
insufficient reason to justify language changes.

-- 
Posted via http://www.ruby-forum.com/.