Ruby Implementation Shootout 112
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."
Re: (Score:1, Informative)
Re: (Score:2)
hmmm...Could it be the object-oriented programming language Ruby?
Ruby [wikipedia.org]
Re:so... ruby? (Score:5, 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 [wikipedia.org].
And more on Ruby on Rails here [wikipedia.org].
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.
Re:so... ruby? (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 [turbogears.org] and Pylons [pylonshq.com] are very modular (especially Pylons since it's built around the WSGI [wsgi.org] spec). Finally, Python compiles to bytecode whereas Ruby does not. Hence Python outperforms Ruby in almost every shootout [debian.org].
Further reading:
Of snakes and rubies; Or why I chose Python over Ruby [infogami.com]
TurboGears and Pylons (a technical comparison) [ianbicking.org]
From PHP to Python [rightbrainnetworks.com] (my blog)
Re: (Score:3, Informative)
Re:so... ruby? (Score:4, Insightful)
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.
Re: (Score:2)
Same here. I love Ruby, and I love the fact that there aren't any primitive types at all, everything is an object. You can do weird stuff like: a="Hello".downcase.reverse.capitalize That's just cool.
Re: (Score:1, Interesting)
>>> "hello".lower()[::-1].capitalize()
'Olleh'
Code tend to be read more then written. (Score:1)
Martin
Re: (Score:1)
Re:so... ruby? (Score:4, Funny)
Numerical evidence is provided rather than shear opinions.
Do those opinions come from sheeple?
Strings as objects (Score:4, 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)) {
Re: (Score:2)
That's neat, I didn't know java could do that. But your example demonstrates another thing about Ruby I really like, if a function returns a bool, convention is the function should have a questionmark at the end.
...
if a.empty? then
It's very readable, and you know it's testing against empty and not setting it to empty.
Also if a function modifies the object in-place, then convention has it end with a !. So a.capitalize
Re: (Score:1)
Was going to make a comment about the first public releases of Python and Ruby being in 1991 and 1995, respectively, thus making both as old or older than Java. So, guess I just did. Anyway, think you were getting at the people who tout Java, C# etc cau
Re: (Score:2)
Yes, but the expressive nature of Ruby is incredibly addictive. I've used both Python and Ruby, and I'd prefer Ruby any day because the syntax matches my thought processes more than Python. Also, I'm not quibbling over invisible things like newlines and tabs.
These things are qualitative rather than quantitative, and I might get used to Python as I work with it over the year, since it's my next Language of the Year.
Re: (Score:1, Insightful)
Well thought of is debatable as RoR is an "opinionated software": if you don't like the way DHH (the framework's creator) works you're going down fast.
Efficient, no damn way, Rails itself is not really fast and it's implemented on top of a very slow language (Ruby), unless you're talking about programmer time Rails is not efficient at all, and in the programmer-time-efficiency land it has a lot of competition (e.g. Django
Example Code (Score:2)
If you want to learn Rails, well... that's a bit harder. I recommend the Rails Cookbook... lots of good practical code in there. I don't know of a big, open source, Rails website that you can examine though. Haven't looked.
One Criticism of Ruby, But a Major One (Score:2)
I love Ruby. I did a RoR project, learning Ruby and RoR at the same time, got the whole thing up and working in 3 odd weeks. I was impressed with the elegance of the Ruby API and even more so with the supreme elegance of the Ruby on Rails API - it's awesome. It's what's Java with its mess of backwards compatible and not-well-thought-out and clunky APIs can only dream of. [Note: I am a professional Java dev]. Things that should only take a line of code, do. Unlike Java where they take 2 classes,
Re: (Score:1)
Then start to play with it and look at the API. The documentation is javadoc like (rdoc).
If you want to see code, try the "Rails Recipes" book. Though this will only get you through some tricks, not the base of your app.
Re: (Score:1)
Re:so... ruby? (Score:5, Informative)
"Shear" opinions (Score:1, Funny)
Numerical evidence is provided rather than shear opinions.
Would that be what the author thinks about scissors? For the semi-literate that should be "sheer opinion," not "shear opinions."
Re: (Score:1, Insightful)
Read the disclaimer... (Score:3, Insightful)
Re: (Score:1)
In the first table, he uses an arithmetic mean, which is invalid as it unfairly weights slow benchmarks. This has the effect of making the windows version look bad, as against the equivalent linux implementation, the longest benchmark is nearly 30s slower on the windows box, so I was almost tempted to not mention it, and let windows look bad. The correct mean to use
Re: (Score:2)
Also note that "average and Median values take in consideration only working tests (they exclude âToo longâ(TM) programs as well)", so the averages for Cardinal and Rubinious with many errors are of dubious utility.
Cardinal interesting (Score:4, Interesting)
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?
Re: (Score:2, Insightful)
Re: (Score:2)
You have to figure out the equivalent tasks(Mandelbrot seems to be be one) and then flip between the two benchmark pages.
Re: (Score:2)
Re: (Score:2, Informative)
Note that Parrot has had little optimization too.
No, that's not interesting. (Score:1)
If your program doesn't have to return the right answer, it's very easy to make it go really fast.
cool (Score:1)
Re: (Score:1)
It's right there under the large "Benchmark Environment" heading.
A shear opinion... (Score:2, Funny)
Try "sheer".
Re: (Score:1, Funny)
An y'all don' wan' nunna my rake-fu!
Java not slow enough for you? Try Ruby! (Score:4, Insightful)
Re: (Score:3, Insightful)
Re: (Score:1, Informative)
Re: (Score:3, Insightful)
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.
Re: (Score:1)
Re: (Score:2)
Perl 5 is when things finally got interesting. I hated Perl 4, but I don't think I could live without Perl as it is today!
Granted, Perl pales in comparison to Ruby when it comes to "interesting" (and I mean that in a good way! (for ruby))
Use the right tool for the job. And that depends on the job, the toolbox, and the programmer. For example, for interfacing with our hideous OSS gateway most programmers would use Java. I would use a length of steel rebar and a lot of foul language
Re: (Score:2)
Re: (Score:2)
Re: (Score:3, Insightful)
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 [slashdot.org] two (both?) of the JRuby developers and progress has accelerated [codehaus.org]. The promise is a highly capable Ruby implementation running on a JVM. This, coupled with very recent changes to the JVM [artima.com] to facilitate scripting langua
Re: (Score:2)
There is no justification for this statement. One of the aims of JRuby is to compile to JVM byte code, which can then be translated to highly optimised machine code.
Apparently Sun isn't content to let Microsoft's CLR become the de facto standard bytecode runtime platform.
Do you realise how many instances of the JVM there are right now? Not just on servers, but on mobile devi
Re: (Score:2)
Any YARV experts (Score:3, Insightful)
Re:Any YARV experts (Score:4, Informative)
Slightly less short answer: if I'm not mistaken, YARV includes a JIT compiler, similar to what Psyco [sourceforge.net] 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.
Re:Any YARV experts (Score:5, Insightful)
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.
Re: (Score:2)
unicode? (Score:3, Interesting)
Ruby and Unicode (Score:3, Interesting)
Re: (Score:1)
AAAAARGH!! (Score:2)
> vector of 8 bit bytes
No. No, no, no. NO. Please, no. Seriously. This is bad. A LOT of damage happens because people can't be bothered to spend the 10 minutes it takes to learn the basics of Unicode. It's easy. I don't always think very highly of what Joel Spolsky writes, but his introduction to Unicode [joelonsoftware.com] is an ABSOLUTE must-read.
Seriously. Strings are NOT interchangeable with byte arrays. EVER. Without an enc
Re: (Score:2)
Want unicode? Try tcl (Score:2)
Suggest you to start with this page [wiki.tcl.tk] to get a glimpse of what Tcl is all about!
Re:Want i18n? Try .NET (Score:2)
Of course you have to manually translate text strings into resource files for each language, but once you do that, programmatically switching b
Re: (Score:2)
More importantly, pervasive OS support for Unicode is one thing, but making i18n support easy for developers is someting else entirely. A more apt comparison would be
Feature comparison? (Score:2)
I don't think anyone decides to use Ruby based on performance, really. I'd be a lot more interested to hear whether any new features (notably, proper Unicode strings and native threads) are included in any of these implementations -- I really can't use Ruby without at least the former. I would have thought the Java and
Re: (Score:2)
http://www.headius.com/rubyspec [headius.com]
Also discussed was specification through tests (that is, if an implementation passes the unit tests for the most commonly used set of ruby applications/libraries, then it is good enough).
For the notes on the summit:
http://wiki.rubygarden.org/Ruby/page/show/RubyImpl emntersSummit2006Nov [rubygarden.org]
http://www.google.com/search?q=cache:wylYVnj0RpIJ: wiki.rubygarden.org/R [google.com]
Re: (Score:1)
Good news on Yarv speed improvements (Score:2)
I would have prefered Ruby, BTW, because it is easy to train people in Ruby development while Common Lisp is a harder learning curve.
Once Yarv is very stable (maybe it is already?), then I will use Ruby for a larger percent of my new proj
Re: (Score:2)
My irb-yarv will not work (for me), but I have tried running ruby-yarv against the examples for my in-progress "Ruby AI" book and did not see any problems.
Yarv will be cool! Especially when it supports Rails.
Ruby's Windows support (Score:1)
Granted, Ruby is mostly used with Rails right now, but you'd think that if the language proponents want the language to take off, Windows support would be taken more seriously. In the couple years since I first tried Ruby, it doesn't seem like it has improved much at all.
Re: (Score:1)
Most servers are going to be running a *nix, and the primary domain of scripting languages is the command line and the server. If someone is running Windows as a web-server, they most likely will be using
As Ruby matures, so will things like performance and secondary OS support. JRuby and Ruby.n
Re: (Score:1, Insightful)
Perl, for one, acquired decent Windows support in the late 1990s... at a time when it was younger than Ruby is today.
Re: (Score:3, Insightful)
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 u
Re: (Score:2, Interesting)
Re: (Score:2, Insightful)
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.
Re: (Score:2, Informative)
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 t
Re: (Score:1)
Matz, I suspect, who started in February 1993, if I recall correctly.
Immature, maybe, but it's about the same age as Java.
Re: (Score:2)
I think the "it just works" philosophy of the Mac has a lot in common with the similar philosophy of Ruby and Rails. So if you are attracted to Rails you are likely to be attracted to Apple products and vice versa.
Since Ruby adoption is l
Re: (Score:2)
Gack! Somebody needs to hire a graphic designer quick. That site is NOT a promising endorsement for RoR...
Re: (Score:2)
The big problem I have, though, is that most sites I see created by designers seem to follow the same rather boring mold. Every site developed in the last year or two looks just like every other site developed in the last year or two.
I'd appreciate knowing what it is that creates such a negative reaction to what I've
Design (Score:2)
You have three choices: 1) hire a designer; 2) get a template; 3) find a designer.
You've already indicated you don't want to do nu
When your server is Linux... (Score:2)
And if your server is Windows, I'd say you're on your own. If, for some perverse reason, you want it to work well, the code is there, but why should we help you?
Re: (Score:1)
I do not want to deploy Linux on my home machines, but a couple of my sites are hosted on Linux with Rails. It would be nice to be able to work locally with the same apache-mysql-ruby config, even though I don't want to install Linux at home. Ruby also would have probably made more inroads into my Windows-centric workplace if it had better support, but instead I went with ASP.NET after failing to get Rails on Windows to work effectively on Windows with Apache a
Re: (Score:1)
I highly doubt a Window-centric Corporation would retrained all thier developers, and switch to an open source laungauge that isn't supported by Microsoft only if it had "better support". I call shanigans. Ruby is making inroads in PHP, Perl, and Python shops; I woudln't hold my breath for Windows shops. I have many clients like this, they rarely even know ab
Re: (Score:2)
You could mess with it on the server, which was my point. What makes your local Windows machine more convenient?
I could make this into a big deal about you refusing to roll out Windows at home, but I imagine this is closer to a minor inconvenience than a major stumbli
Re: (Score:2)
Re: (Score:1)
Anyway, to the other posters: Don't shoot the messenger telling you that Ruby sucks on Windows. As I said, TFA points it out very well by having tests that crash out completely on Ruby 1.8.5 for Windows. It's not g
Why not use C (Score:4, Funny)
Re: (Score:2)
Amen. With critical functions (XML parser, for instance) rewritten in assembly for speed.
Re: (Score:2, Insightful)
But really, Ruby's for more than just Web stuff. (As is Python and the rest.)
Re: (Score:2)
And they deserve it. Everyone who uses C++ but not the std::string class it comes with does so.
Re: (Score:2)
But really, Ruby's for more than just Web stuff.
Amen. I'm not the biggest fan of RoR - I don't find it all that fast unless you're building a ground-up app, and even then it bugs me sometimes.
Ruby for other things - text parsing and the like is just awesome. I have a hard time with some doofuses in my office explaining them that Ruby on Rails != Ruby...
Because C is a system programming language. (Score:1)
Yes you can use C for all sorts of other programming needs (if you have a masochistic tendence) - all programming needs in fact as C is turing complete - but it isn't any good at it.
Martin
Note: I have learned C in 1990, updated my C knowledge regularly, own a copy of the C99 ISO standard and I have quite a lot