Mirah: A Ruby Syntax for Java
There's been an explosion of interest in alternative JVM languages over the past couple years, which has seen the rise of Scala, Clojure, and Groovy, in addition to re-implementations of existing languages like JRuby and Jython.
The most recent JVM language to really capture my attention is Mirah. Created by Charles Nutter, who is perhaps most well-known as one of the JRuby core team member, Mirah's syntax is unsurprisingly inspired by Ruby. However, unlike JRuby, Mirah is statically typed (with local type inference) and compiles directly to Java bytecode without the need for any bundled-in interpreter.
When Nutter created it about two years ago, it was a hobby project (originally called Duby), an attempt to see how much of the things he liked about Ruby he could implement without requiring a runtime: "I started to realize it was really just a few key features from Ruby that I wanted: nice literals, clean syntax, basic closure support, iteration. I started wondering how many of these things can I implement without any runtime, just generating Java bytecode directly. How far could you take that? And it turns out you can actually take that a long way. You can do a lot of what people love about Ruby without doing anything more complicated than what Java does."
Mirah syntax generally looks very similar to Ruby, and many Ruby developers who have played with it immediately brand it as "statically typed Ruby". Here's an example Fibonacci program, from the collection of Mirah sample code. Note that the argument type is declared, but that the return value is inferred and does not need an explicit declaration.
def fib(a:fixnum) if a < 2 a else fib(a - 1) + fib(a - 2) end end
Although it's still young, Mirah is already being used by a handful of people for production purposes. There's currently interest in using Mirah for building and deploying web applications on Google App Engine, which has led to the development of the Dubious framework, a slick Sinatra-like web framework. There's also a lot of interest in leveraging Mirah for Android application development.
My personal interest in the language was sparked by a Rubyconf talk on Ruboto, an effort to make (J)Ruby a viable option for Android application development. Ruboto itself is a compelling project and one that I'm sure will help make Ruby a more attractive option for mobile dev. However, Mirah may be even more suitable for Android work because of it's ability to compile straight down to bytecode without the need for a separate runtime, meaning smaller APK sizes and quicker startup times.
Both of these projects are still relatively new, but interest in Mirah is growing quickly within the Ruby and Java communities. At Rubyconf alone, there were at least 4 talks that included mention of Mirah in some way and it seems like a language that could have wide appeal. "You can do so much for a language just by adding a little more [syntactic] sugar", says Nutter, "and that's really what Mirah does for Java. It's a Ruby syntax for writing Java code."