Slashdot Mirror


Ruby Implementation Shootout

An anonymous reader writes "Ruby has an ever growing number of alternative implementations, and many of these attempt to improve the suboptimal performance of the current mainstream interpreter. Antonio Cangiano has an interesting article in which he benchmarks a few of the most popular Ruby implementations, including Yarv (the heart of Ruby 2.0), JRuby, Ruby.NET, Rubinius and Cardinal (Ruby on Parrot). Numerical evidence is provided rather than shear opinions. The tests show that Yarv is the fastest implementation and that it offers a promising future when it comes to the speed of the next Ruby version."

26 of 112 comments (clear)

  1. Read the disclaimer... by tcdk · · Score: 2, Insightful
    This being /. I don't expect anybody to actually read the acticel, but before you begin your rant^H^H^H^H ... post about how these tests are useless etc. etc. please, at least read the article disclaimer:

    Don't read too much into this and don't draw any final conclusions. Each of these exciting projects have their own reason for being, as well as different pros and cons, which are not considered in this post. They each have a different level of stability and completeness. Furthermore, some of them haven't been optimized for speed yet. Take this post for what it is: an interesting experiment; Now fell free to begin your rant about it being a slow news day...
    --
    TC - My Photos..
  2. Re:so... ruby? by spellraiser · · Score: 4, Informative

    I was on the same boat until a couple of weeks ago ... anyway, Ruby is The Hottest Thing Since Sliced Bread (TM). It's a programming language that was created in Japan all the way back in 1995. However, it has only just recently garnered mainstream interest due to the emergence of a web application framework built on Ruby, which is called Ruby on Rails and is said to be an incredibly well-thought and efficient framework.

    More on Ruby here.

    And more on Ruby on Rails here.

    I personally have an enormous interest in Ruby on Rails, as it seems to be a very neat way of writing web applications, but I'm also a bit daunted; it's a new language and a whole new framework with different ways of doing things, so it's been slow going learning it. I just wish I knew where to get some extensive sample code to peruse - that's how I learn best. All I've seen are some very basic applications which don't really teach you the real tricks and show how it all comes together.

    --
    I hear there's rumors on the Slashdots
  3. Cardinal interesting by mattr · · Score: 3, Interesting

    Though not familiar with the project, I'm impressed that the project with by far the most errors (Cardinal), indicating I assume that the least work has been done on it, is still so close to YARV - only 2-4 times slower in a couple tests.

    I can't tell if those fast tests are so trivial that they offer little chance of further speedup, or whether YARV, which has had speed as a goal, is not going to be so much faster than a Parrot-based implementation once it (Cardinal) gets into working on optimization.

    Anyone interested in providing some information on where the YARV performance comes from and whether Cardinal is likely to approach it more closely and farther across the board in the tests?

    1. Re:Cardinal interesting by archen · · Score: 2, Insightful

      Personally what annoys me more is that this is giving me no benchmark against how ruby in general is performing. Maybe something is twice as fast, but twice as fast as what? Slow as hell? My understanding is that ruby has always lagged a bit in the performance sector, although maybe that has improved over the last 2 years. I'd be more interested to see additional benchmarks against equivalent programs in Perl5 which is sort of the interpreter execution standard, or maybe something in C.

    2. Re:Cardinal interesting by chromatic · · Score: 2, Informative

      Note that Parrot has had little optimization too.

  4. Re:so... ruby? by Phrogz · · Score: 4, Informative

    Ruby is a dynamically typed, strongly typed, runtime-interpretted, very object-oriented programming language. It was created about the same time as Python (10+ years ago?), but is less well-known in the United States as it originated in Japan. It is the langauge that the Ruby on Rails web framework is based on. See the official Ruby website for more information.

  5. Java not slow enough for you? Try Ruby! by Jagasian · · Score: 3, Insightful

    Performance isn't everything, but then again, when you are 400 times slower than Java... performance starts to matter.

  6. Any YARV experts by Timesprout · · Score: 2, Insightful

    Can anyone comment on why the YARV implementation is so much faster than the standard implementation? I know for example the SUN VM was originally only intended as a reference VM and faster implementations were developed but not on the scale of the differences highlighted here.

    --
    Do not try to read the dupe, thats impossible. Instead, only try to realize the truth
    What truth?
    There is no dupe
    1. Re:Any YARV experts by Balinares · · Score: 3, Informative

      Short answer: various things, compilation to bytecode before execution (I thought it was the case in the current interpreter, but might have been mistaken), etc.

      Slightly less short answer: if I'm not mistaken, YARV includes a JIT compiler, similar to what Psyco does in the Python world. Psyco has been known to accelerate code execution up to 100x times, so I'd expect YARV to be even faster than this benchmark shows when it's stabilized.

      --

      -- B.
      This sig does in fact not have the property it claims not to have.
    2. Re:Any YARV experts by mo · · Score: 4, Insightful

      The standard 1.8.X Ruby interpreter is a single-pass interpreter, and YARV is a virtual machine implementation. You can expect big improvements when moving to a VM implementation from an interpeter. The reason Java has never had such big improvements is that it's always been based on a VM.

      This rule isn't exactly hard and fast, as verying implementations of VMs and interpreters can have different performance characteristics. For example, while perl is still probably considered an interpreted language, it's quite fast due to the interpreter using many compiler tricks such as parse tree optimizations. The ruby interpreter however has been notoriously slow, which is why ruby people are so excited about it.

  7. Re:so... ruby? by XorNand · · Score: 5, Informative

    Yes, Ruby is the current web development flavor of the month, however, don't get caught up in the hype. There are good number of MVC web development frameworks in other languages, including even Lisp and Smalltalk, but most notably Python. In my opinion it makes more sense to learn a Python framework for a number of reasons. Mainly because Python is used in considerably more non-web applications than Ruby, which makes your skills more portable (and you more employable). Ruby on Rails is also very monolythic, while two of the the three most popular Python frameworks, TurboGears and Pylons are very modular (especially Pylons since it's built around the WSGI spec). Finally, Python compiles to bytecode whereas Ruby does not. Hence Python outperforms Ruby in almost every shootout.

    Further reading:
    Of snakes and rubies; Or why I chose Python over Ruby
    TurboGears and Pylons (a technical comparison)
    From PHP to Python (my blog)

    --
    Entrepreneur : (noun), French for "unemployed"
  8. unicode? by bcrowell · · Score: 2, Interesting

    What's up these days with ruby and unicode? Of these implementations, do some do it one way and some another?

  9. Re:Java not slow enough for you? Try Ruby! by arevos · · Score: 2, Insightful

    Performance isn't everything, but then again, when you are 400 times slower than Java... performance starts to matter. Sure, if you're interested in generating mandelbrot fractals or the spectral norm of a matrix. However, Ruby typically isn't used for such computationally intensive tasks.
  10. Re:so... ruby? by daeg · · Score: 2, Informative

    If you're going to mention Web Python Frameworks, don't forget Django. Honestly they are all really good choices (Pylons, TG, Django, etc). I know you mention it in your "why py?" post, well, assuming it's the same post I read a few months back. :)

  11. Re:so... ruby? by Stamen · · Score: 4, Insightful

    Minor note, Ruby on Rails is the web development flavor of the month, not ruby. There are a lot of interesting things happening in plain ole ruby, plus there are other web frameworks than Ruby on Rails, such as Nitro, Camping, etc.

    I find it amusing someone would say learn Python because it's used more. Python may be older, but it's still sitting in the programming language high chair right next to Ruby. People say the same thing about Python; "if you want a job learn Java, c#, c++"; and you know what they're right, if you want a job learn Java, period.

    I like both Ruby and Python, and I think a programmer would do well to learn one or both. They aren't as popular yet, like Java or c#, but I think they will be. And if you understand the concepts in one, you'll understand the other. Like Gretzky said, "I skate where the puck is going to be, not where it is"; good advice.

    I prefer Ruby, but that is just a preference.

  12. Ruby and Unicode by metamatic · · Score: 2, Interesting

    What's up is that there's massive disagreement on whether Ruby's standard strings and characters should become Unicode. There are quite a few people used to the old world where a string was interchangeable with a vector of 8 bit bytes, and they don't want to let go. To add to the problems, Unicode is controversial in Japan. So, expect Unicode to continue to be painful and inconsistent in Ruby even after the next major release.

    --
    GCHQ Quantum Insert installed. If only our tongues were made of glass, how much more careful we would be when we speak
  13. Re:Java not slow enough for you? Try Ruby! by TopSpin · · Score: 2, Insightful

    Performance isn't everything, but then again, when you are 400 times slower than Java..

    400 times slower? Still too efficient. Consider a Ruby implementation on the JVM and multiply inefficiencies! Should be thousands of times slower for those same benchmarks.

    About JRuby; Sun recently hired two (both?) of the JRuby developers and progress has accelerated. The promise is a highly capable Ruby implementation running on a JVM. This, coupled with very recent changes to the JVM to facilitate scripting languages could lead to an interesting future. Sun is also leveraging the JVM for other language projects such as Fortress.

    Apparently Sun isn't content to let Microsoft's CLR become the de facto standard bytecode runtime platform. I don't know whether it's possible to make Ruby performance on the JVM competitive with native implementations, but I am hoping.

    --
    Lurking at the bottom of the gravity well, getting old
  14. Why not use C by zymano · · Score: 3, Funny

    C and cgi.

    1. Re:Why not use C by FrnkMit · · Score: 2, Insightful

      I worked briefly at a shop that used C and C++ for CGI. They were still struggling with memory errors in their in-house string libraries.

      But really, Ruby's for more than just Web stuff. (As is Python and the rest.)

  15. Re:Ruby's Windows support by shmlco · · Score: 2, Insightful

    "As Ruby matures, so will things like performance and secondary OS support."

    And when will that happen, exactly? I've been hearing about R/RoR for years now, and it's still distinctly in the low-performance category. Yet every time I go visit the site for updates all I see is talk about how they're adding feature X and Y in the next point release.

    These guys need to stop dinking with the language, freeze it, and work on fixing bugs and increasing performance so people out here in the real world can actually use it.

    Unfortunately, like most OSS projects it seems that it's cooler to add the feature-of-the-day, rather than do the actual work needed to make it a stable and solid development platform...

    --
    Any sect, cult, or religion will legislate its creed into law if it acquires the political power to do so.
  16. Re:Ruby's Windows support by chromatic · · Score: 2, Insightful

    I think this is just because of the age of the language, as the same was true for Perl and others when they were young.

    Ruby's almost 14 years old! By 2001, Perl had fantastic Windows support.

    Now people may deploy Ruby or Perl or Python or PHP applications to Unix and Unix-like servers, but I know plenty of people who develop on Windows. Some of them even have a choice.

  17. Re:Java not slow enough for you? Try Ruby! by Rufty · · Score: 3, Insightful

    Yep, I agree. Ruby's slow. Probably slower than the rest at just about everything.
    Except speed of code development.
    So for my one-off scripts that run for 45s in ruby instead of 0.1s in perl, well
    what's mattered to me is that it took 5 mins to write, rather than the 90mins +
    a brain tumor that perl does*

    * I last used perl at about 4.036, tried to get into "objects" with perl 5, and
    jumped to ruby for the sake of my sanity.

    --
    Red to red, black to black. Switch it on, but stand well back.
  18. Re:Ruby's Windows support by zallus · · Score: 2, Interesting

    make it a stable and solid development platform...
    Whoever said that was their primary, or even secondary goal? I use ruby as a prototyping language before rewriting in C. I only use it because it's so easy to work with all the "features of the day" in it.
    --
    I mod down pathetic posts.
  19. Re:Ruby's Windows support by Stamen · · Score: 2, Informative

    12 years old (December 21st, 1995) but who's counting a few years.

    First off, the parent of my post said that the Windows port wasn't as fast as Linux and should be supported and worked on more. Ruby supports Windows just fine thank you.

    Second, Ruby has had an interesting history. It was basically unknown in the west until Dave Thomas and Andy Hunt wrote the first book in English in 2000. At that time, the language started to take off, and only in the last few years has development really ramped up. So technically it is 12 years old, but in reality it is a very new language.

    Unless you have Microsoft (.net) or Sun (Java) putting a huge amount of resources into development, languages take a long time to fully bake. This is normal, expected, and desired.

    Choose to use Windows for development... heh, you almost had me there, nicely done.

  20. Re:so... ruby? by ralphdaugherty · · Score: 3, Funny

    from the summary:
    Numerical evidence is provided rather than shear opinions.

          Do those opinions come from sheeple?

  21. Strings as objects by RallyDriver · · Score: 3, Interesting

    Well, you can also do it in Java .....



    String a = "Hello".toLowerCase().toUpperCase();

    .... but I'm not sure it makes a huge difference in real software development. I do however like it as the safe test for an exact match without worrying about null ....



    if ("FOO".equals(a)) { ....