First of all, slower with respect to what? C? Python? Let's get some numbers at the Computer Language Benchmarks Game:
- Ruby 1.9 vs. Python3 within the same order of magnitude
- Ruby 1.9 vs. PHP within the same order of magnitude
- Ruby 1.9 vs. Java 6 server up to two orders of magnitude slower!
- Ruby 1.9 vs. C (gcc) up to two orders of magnitude slower!
- ...
Why is Ruby considered slow?
Depends on whom you ask. You could be told that:
- Ruby is an interpreted language and interpreted languages will tend to be slower than compiled ones
- Ruby uses garbage collection (though C#, which also uses garbage collection, comes out two orders of magnitude ahead of Ruby, Python, PHP etc. in the more algorithmic, less memory-allocation-intensive benchmarks above)
- Ruby method calls are slow (although, because of duck typing, they are arguably faster than in strongly typed interpreted languages)
- Ruby (with the exception of JRuby) does not support true multithreading
- etc.
But, then again, slow with respect to what? Ruby 1.9 is about as fast as Python and PHP (within a 3x performance factor) when compared to C (which can be up to 300x faster), so the above (with the exception of threading considerations, should your application heavily depend on this aspect) are largely academic.
What are your options as a Ruby programmer if you want to deal with this "slowness"?
Write for scalability and throw more hardware at it (e.g. memory)
Which version of Ruby would best suit an application like Stack Overflow where speed is critical and traffic is intense?
Well, REE (combined with Passenger) would be a very good candidate.