JRuby 1.6.0 Released: Now with Ruby 1.9.2 Support
jruby.org
jruby.org
I often think that the Ruby world would be a more productive place if the original implementation had leveraged the JVM.
http://erik.debill.org/2011/02/03/ruby-performance-in-the-ra... http://erik.debill.org/2011/02/19/ruby-start-up-times
And the Torquebox team (Torquebox being a JRuby Rack app server using JBoss) also did some benchmarks and discovered (surprise, surprise) that Torquebox on JRuby significantly outperforms the alternatives on 1.9.2:
http://torquebox.org/news/2011/02/23/benchmarking-torquebox/ http://torquebox.org/news/2011/03/14/benchmarking-torquebox-...
(Disclaimer: Of course, benchmarks aren't authority figures so it's always worth running them for yourself..)
Then there's algorithms, support for just about any protocol under the sun. And the Java standard library is surprisingly complete as well - what you need might even be installed with your JVM.
Try googling for a Java library next time you think of something you want to do.
This kind of turned in to a spreadsheet gem rant, but if you step back, it's typical of a greater problem. The Ruby community is relatively small when compared with the Java community. It's also significantly less "enterprisey". This means that you'll see a lot of effort put in to things that developers like -- clever libraries, syntactic "sugar", etc -- but you're less likely to see mature libraries like Apache POI. Who the hell wants to sit around and figure out BIFF8, anyway? A lot of the enterprise stuff just isn't fun, but there are plenty of Java devs who get paid to do it for their day jobs.
By using JRuby, you can benefit from both worlds.
... if the original implementation had leveraged the JVM
I think that's a horrible idea. The JVM is an awful platform for any kind of language research & development, unless the type-system of that language is basically the same as in Java. I'm actually pretty upset that they've taken continuations out from 1.9 - most likely JRuby bares some blame.Not to mention I would prefer to keep Oracle(TM) tainted stuff out of my lawn, as at this point I consider Mono/.NET to be more safe than Java.
What I really want and what is needed - a reference implementation written in 80% Ruby (or more). That's like Rubinius or Pypy, but adoption isn't great even though these virtual machines have shown better performance than the reference implementation for computational-heavy tasks.
And adoption isn't great because remarkable libraries written in native code won't run reliably or at all on top of them (e.g. Python's Scipy).
And JRuby shares the same problem, although it has the advantage of being able to use JVM-alternatives. But then you're stepping out of the Ruby ecosystem, which makes it a fork.
And to get back to "JRuby as reference implementation" ... it would be an even greater pain in the ass for alternative implementations, because C is more portable than Java.
Also, native libraries are becoming less of a problem now that libffi has a bit of momentum.
https://github.com/strobecorp/kirk
It's a really nice jetty binding for jruby.
It's wicked fast.
Now I really wish some more work was being done on Jython because Jython and AppEngine is what is holding back Django from moving to Python 3+.
There are ways for JRuby to do an actual real live OS fork, but they aren't especially pretty.
As far as rewriting your code, would it be that difficult to change it to use threads? They don't FORCE you to share state, and there are powerful primitives for message-passing in java.util.concurrent. As long as you're not abusing global variables in Ruby it should translate over just fine.
It's not implementing message passing that's the problem, it's the shared state, multi-threaded model in general. It's too easy to trip up, so I prefer fork() and message-passing. I am less worried about my own code, but what future maintainers who have less experience in concurrent programming will have to deal with.
It's just a framework for a pool of workers that hang off an MQ, so fork() also provides some extra resiliency in the event that something bad happens.
It's not as memory efficient as MRI, but isn't _too_ bad unless you're on a cheapo memory constrained VPS.
Imagine if this much effort had gone into 1.9.2 instead?
YARV may start to lag behind in performance measurements, but it's already faster than many popular runtimes (Python, for example) and there's nothing stopping them from making more drastic moves to improve it (adding JIT or concurrent threading).
And of course they are still the reference implementation; we want them to continue to push the boundaries of what Ruby can do, and continue to challenge us with new features.