On Feb 2, 2012, at 14:20 , Dmitry Nikiforov wrote:

> Ruby:
> 
> for a in 0..1E8
>        a*2
> end
> 
> Perl:
> 
> for $a ( 0..1E8 ) {
>        a*2
> }
> 
> Ruby takes 22 seconds, Perl - 9 seconds to execute this. This is very
> similar to all other scenarios I tried (one of which is splitting
> millions of comma separated rows into arrays).
> 
> I would really appreciate any useful suggestions: I would LOVE to be
> able to use Ruby for most of the stuff I do (it's not that I don't like
> Perl, but I love Ruby's syntax :) )

Choosing the right language is a lot less important than choosing the right algorithm:

5461 % time ruby -e 'n = 10**8; p (n + 3*n**2 + 2*n**3)/6'
333333338333333350000000

real	0m0.009s
user	0m0.004s
sys	0m0.004s

In most cases (depending on the domain, of course (*)), ruby is "fast enough". Often, with my slower ruby, I'll finish coding long before you would in your faster language. This coding-time difference is usually sufficient to deal with run-time differences.

*) your domain is fast enough unless you work for the IRS, NASA, wallstreet **, or pixar ***.
**) sufficient examples exist to show that those domains are also fast enough.
***) prolly not here tho.