O'Reilly logo

Addison-Wesley Professional Ruby Series Writing Efficient Ruby Code by Dr. Stefan Kaes

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter . Ruby’s Interpreter Is Slow

Yes it is. And I’m not the only one who thinks so. Even the creator of Ruby, Yukihiro Matsomoto (a.k.a. matz), has publicly stated this. Apart from benchmarking some algorithms in Ruby and comparing the results with implementations of the same algorithm in other languages, one can look at the source code of Ruby’s interpreter and derive some reasons why it is slower than interpreters of comparable languages (e.g., Perl and Python).

Ruby’s interpreter does not compile the source code into instructions for a virtual machine. Instead, Ruby uses abstract syntax trees to represent code internally. Traversing a tree structure at runtime is known to be slower than interpreting a linear sequence of virtual machine instructions. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required