From: Samuel Williams Date: 2010-03-30T22:04:55+09:00 Subject: Re: Programming Language Comparison Dear Josh, Those are all really good points. Ruby does have many ways to do things. So does Perl. I wonder if this is really a disadvantage? I guess it potentially makes the language tricky if different ways of doing things have subtly different implications. Kind regards, Samuel On 31/03/2010, at 1:59 AM, Josh Cheek wrote: > Another thing to consider is that Perl is being demerited for TIMTOWTDI, but > Ruby is not. Yet how many ways are there to loop from 0 to 2 in Ruby? > > results = Array.new > > 3.times { |i| results << i } > > (0..2).each { |i| results << i } > > 0.upto(2) { |i| results << i } > > 0.step(2) { |i| results << i } > > (0..2).to_a.each { |i| results << i } > > for i in 0..2 do results << i end > > i = 0 > while i <= 2 > results << i > i+=1 > end > > i = 0 > until i > 2 > results << i > i+=1 > end > > i = 0 > loop do > results << i > break if 2 < i+=1 > end > > puts RUBY_VERSION > results.join.scan /.../ do |result| > puts result > end > > > > There are also a few additional ways in Enumerable that aren't shown here > b/c they don't work on 1.8.6 > > And I left out array based solutions, because while they will work in this > small range, that is not what they are there for, and so will quickly become > unmanageable. ie [0,1,2].each {} might work but is not scalable if you want > to iterate the first hundred numbers, and is not dynamic if you want to be > able to determine your range from variables. > > ----- > > And I don't know enough about Perl to answer this, but I'd be interested to > know from anyone who does, whether Perl is actually difficult to read, or > whether that is just a consequence of certain styles of coding that get the > most attention or have become idiomatic within the Perl community.