While JRuby's performance rivals or exceeds other Ruby interpreters, the fastest JRuby code still lags pure Java performance by an order of magnitude. While you can expect the performance of JRuby to improve with the 1.6 release, Mirah is an attempt to break through the performance ceiling and provide an option for programmers looking for execution speeds on par with Java code.
Mirah: Java's Ruby
Mirah is an attempt to take the Ruby language, make some minimal changes to the language and create a new language which can be compiled to bytecode. Mirah's challenge is to take Ruby, make minor modifications to the language, but not too many to change the 'Rubyness' of the language: the simplicity and usability of Ruby. In this post, I interview Charles Oliver Nutter one of the core commiters on JRuby and the founder of the Mirah project to put the project into perspective.
Interview with Charles Nutter
A: Programming languages seem to be my current niche, so this really is what I do with my spare time! In this case, it's an itch of mine that no other languages appear to scratch: a language with a rich but lightweight syntax that doesn't impose its dependencies upon me. I write Java most of the time and Ruby the rest, so it seemed natural to come up with something in between. Mirah uses Ruby-like syntax, but brings along no runtime library. It's the parts of Ruby syntax I love best, with a few of Ruby's features, but no more imposition on my development and deployment processes than writing in Java and using javac.
Q: What are some of the advantages of Mirah vs. JRuby.
A: Mirah, being largely a thin veneer over the underlying "native" platform, runs as fast as the best languages on that platform. In concrete terms, code written in Mirah will perform exactly as well as code written in Java, but look and feel a lot nicer in the process.
JRuby goes much farther in terms of providing a rich platform, since it's essentially emulating the entire Ruby platform atop the JVM. If you need that platform or applications and libraries built for it, JRuby's still the right choice. But if you're mostly interested in the "apparent" syntactic and semantic features of Ruby and still need the benefits of a statically-typed language, Mirah may be the way to go.
Q: Why would someone program in Mirah versus a similar language like Groovy? Other than style preferences, what differentiates Mirah from other languages which run on the JVM?
A: Much of the benefit of Mirah over similar languages comes down to being so lightweight. In Groovy, Scala, JRuby, Clojure, or Jython, the minute you write "Hello, world", you've shackled yourself to a runtime library. In Mirah, "Hello, world" is just as terse as in JRuby, but has the added benefit of not foisting any dependencies on you; source file goes in, class file comes out, and that's it. I believe the JVM needs a new dependency-free language, and Mirah is my attempt to deliver one.
Q: Why the name change? This was called "Duby" for a while, and it seemed to be a side project?
A: Duby was originally a portmanteau of "Duke" (the Java mascot) and "Ruby", but due to the similarity to words like "doobie" and giggling that produced, I decided to change the name. But I wanted to still be clever about it; "mirah" means "ruby" in the Javanese language (of the island of Java). So Mirah is Java's Ruby. Get it?
Q: During your Railsconf 2009 presentation, you allude to the popular belief that JRuby is really just "Ruby for Java Programmers". Ruby (especially the Rails crowd) has always been very hostile to Java as a language and as a culture. As JRuby has come to be seen as a real deployment platform, how has the community evolved.
A: We've always known that JRuby's Java roots have kept folks from using it or contributing, whether because they don't know Java or because they have their own bigotries about the language or platform. Mirah started as an attempt to provide something more "Ruby-like" that Ruby developers could use to contribute to JRuby, but without any loss of performance or platform integration. As time has gone on, JRuby's execution performance has improved to the point where many users actually can just use Ruby. At the same time, people have started to recognize the real benefits of running atop the JVM, their bigotry and aversion to Java and the JVM have softened, and developers already familiar with Java have helped us keep JRuby moving forward. Mirah may still be used to implement parts of JRuby someday, but I think both JRuby and Mirah are doing fine as independent projects.
Q: You mentioned that Rails is "still the big daddy"? As someone who supports Rails deployments, what is the most common deployment approach? jruby-rack? mongrel running under jruby?
The most common approach seems to be using warbler plus jruby-rack to package up a Rails application as a WAR file. Most folks interested in JRuby already have existing Java application servers (or experience with them), so this is an easy choice to make. Among folks who don't run "traditional" application servers, the glassfish and trinidad (embedded Tomcat) gems seem to be the most popular "lightweight" server options.
TL;DR: Mirah is an attempt to create a blazingly fast Ruby-like language that can be compiled to Java bytecode. For more information, go to the Mirah project website: http://www.mirah.org.