As I'm working on JRuby, I obviously think that JRuby is the best solution for many problems I perceive in the MRI implementation currently. I have been quite careful to never say anything along the lines that JRuby is better than anything else, though. I will continue with that stance. However, I won't restrict myself in the same way regarding Rubinius.
In fact, I'm getting more and more convinced that for the people that don't need the things Java infrastructure can give you, Rubinius is the most important project around, in Ruby-land. More than that, Rubinius is MRI done right. If nothing substantial changes in the current timeline and plans for Ruby 1.9.1, I predict that Rubinius will be the CRuby implementation of choice within 6 months. Rubinius is an implementation done the way MRI should have been. Of course, Matz have always focused on the language, not the implementation. I'm very happy about that, since it means that we have an outstanding language.
But still. Rubinius will win over MRI and YARV. I've had this thought for a while, and I'm finally more or less convinced that it's true. Of course, there are a few preconditions. The first and most important one is that Rubinius delivers 1.0 as planned, by the end of the year and that it doesn't have abysmal performance. Or if YARV would happen to be totally finished and perfectly usable in the same time frame, things might take a different turn.
Why is Rubinius so good, compared to the existing C implementations? There are a number of good reasons for this:
- It is byte code based. This means it's easier to handle performance.
- It has a pluggable, very clean architecture, meaning that for example garbage collection/object memory can be switched out to use another algorithm.
- It is designed to be thread safe (though this is not really true yet), and Multi-VM capable.
- It works with existing MRI extensions.
- Most of the code is written in Ruby.
- It gives you access to all the innards, directly from your Ruby code (stuff like MethodContexts/BlockContexts, etc).
- The project uses Valgrind to ensure that the C code written is bullet proof.
Right now we have a simple Rubinius engine in JRuby, that can interpret and run some simpler byte codes from Rubinius.
JRuby and Rubinius are both extremely important. Right now I believe JRuby is more important, since it opens up a totally different market for Ruby, and gives the benefits of Java to Ruby. Rubinius has another place to fill.
Of course, being who I am, I have also looked into what would be required to port Rubinius to Java, using the same approach directly instead of going through JRuby. If you decide to use Java's Garbage Collector, Java Threads, and reuse the JRuby parser you would end up with about 40 files of C code to port. Most of these are extremely easy, and none is really that hard. And what you would end up with is something that would run the same things Rubinius does, but with the possibility of invoking Java code at the same time. (Of course, I hope that Evan reserves a block of about 8-16 bytecodes that can be implementation dependent - these Jubinius would use to interop with Java code).
5 kommentarer:
"It is byte code based. This means it's easier to handle performance."
If by "handle" you mean "not have".
"garbage collection/object memory can be switched out to use another algorithm"
In your dreams. I suspect you'll find out that the architecture isn't as clean as you think it is when you try to plug in some other existing garbage collector or object memory.
It sounds like a good project, but I don't think its advantages are going to be so enormous as you think they are.
I am very fond of the rubinius concept, but I feel some points are sligthly deceiving..
1) yarv has bytecode, it just doesn't dump it (which would be feasible, but koichi wanted to have AOT compilation to C, as the safe/fast deployment strategy, last time I checked).
2) matz implemented a generational GC long time ago, it plugged easily in MRI but didn't bring the expected improvements
3) MVM is planned for yarv too.
4) it works with existing extensions
Anyway, I really hope that rubinius keeps up to the expectations I have for it :)
My first real exposure to Rubinius was at Evan's talk during RailsConf. I'd heard of it, but I'd been completely ignoring it (much like I've been doing with JRuby so far!). But, following Evan's talk -- and his incontrovertable graphs! :-) -- I've decided it's a project I need to take a closer look at.
Did you ever check out http://www.strongtalk.org/. It used to be the fastest smalltalk virtual machine implementation. Then it went open source. It might be worth a look. The company was purchased by sun and some of the work went into the java virtual machine.
I want to like StrongTalk, but the code is totally unreadable, and the implementation is Windows-only.
Last updated in 1996, as well. Very dead.
Skicka en kommentar