Mirah (programming language)

Mirah (programming language)
Paradigm(s) object-oriented, imperative
Appeared in 2008
Typing discipline static, with dynamic features, strong, inferred
Influenced by Ruby, Java, Boo
License Apache 2.0

Mirah (formerly known as Duby) is a programming language based on Ruby syntax, local type inference, hybrid static/dynamic type system, and a pluggable compiler toolchain. Mirah is an effort by Charles Oliver Nutter to create "a 'Ruby-like' language, probably a subset of Ruby syntax, that [could] compile to solid, fast, idiomatic JVM bytecode."[1] The word mirah refers to the gemstone ruby in the Javanese language, a play on the concept of Ruby in Java.[2]



In order to foster more participation in the JRuby project from Ruby community members, Nutter began to explore the possibility of presenting Ruby syntax, but with a static type model and direct-to-native compilation. In this context, "native" meant primarily the JVM, but Mirah has been designed around the possibility of having alternative backends for other object-oriented runtimes like the CLR. The language needed to look and feel like Ruby, but without introducing any new library dependencies into JRuby (which ruled out most other JVM languages) and without suffering a performance penalty (which meant writing in Ruby itself was out).

Early versions of Mirah (then Duby) focused mostly on mathematical performance, where dynamic languages often pay the highest cost. Since then it has evolved into a full-fledged JVM language, with several users and real-world applications using it for core components.


Mirah is largely just a pluggable compiler toolchain. The primary elements of this toolchain are:

  1. A parser, based on JRuby's parser, that produces a Ruby AST
  2. A transformer that converts the Ruby AST into a Mirah AST
  3. A type inferrer that decorates the Mirah AST with appropriate typing information for the target backend
  4. A backend code generator

Of these phases, only the last two require specific knowledge of the eventual target platform. This makes Mirah suitable for many backends, and also makes it possible to write language plugins for Mirah's transformation phase that will apply to all supported backends equally.

For simple pieces of code and the JVM bytecode backend, the Mirah compiler will produce nearly the same instructions as standard javac compilers.

No runtime library

Because Mirah is just a compiler, it ships no standard library. The intent is that Mirah users will choose what libraries they want to use, perhaps write plugins for the Mirah compiler to support them, and the compiler will do the rest. This is an explicit design goal, avoid introducing a requirement on any new external library. The standard library for Mirah, then, is whatever the standard library for the current backend is, and emphasis is placed on writing compiler plugins rather than libraries to extend and enhance the language.

Type system

Mirah does not impose a specific type system on users, instead relying on whatever the target backend provides. On the JVM, the type system is largely Java's type system, and type declarations refer to JVM classes, primitives, and interfaces.

Mirah is primarily a statically-typed language, but support is in development to allow dynamic typing as well. The mechanism is similar to that provided in C# 4, with a special "dynamic" type indicating all dispatches against that variable's value should be done dynamically. Dynamic type support is currently planned only for Java 7 and higher, using the new invokedynamic bytecode.


The syntax of Mirah is largely the same as the syntax of Ruby, but with a few modifications to support static typing:

  • Method parameters usually need to have their types declared:
def foo(a:String, b:int)
  • Because several transformations occur in the Mirah compiler toolchain, some strings that are valid identifiers in Ruby are treated as keywords in Mirah, such as the word "interface" used to specify a JVM-style interface.

Outside of these differences, Mirah code generally looks like Ruby code:

def fib(a:int)
  if a < 2
    fib(a - 1) + fib(a - 2)


Currently Mirah is under development, but there are developers using Mirah for production applications on a limited scope.



Dubious is a project for running Mirah on Google App Engine. Dubious provide a way to build apps in Mirah, with conventions familiar to Rails and Sinatra developers. Since everything is compiled ahead-of-time Mirah apps have none of the initialization costs associated with JRuby. Dubious supports ERb and has a simple datastore adapter that uses a syntax similar to DataMapper.


External links

Wikimedia Foundation. 2010.

Look at other dictionaries:

  • Mirah (disambiguation) — Mirah may refer to the following: Mirah Yom Tov Zeitlyn, an American musician based in San Francisco, California. Mirah (programming language), a programming language for the Java Virtual Machine with a syntax based on Ruby. This disambiguation… …   Wikipedia

  • List of programming languages — Programming language lists Alphabetical Categorical Chronological Generational The aim of this list of programming languages is to include all notable programming languages in existence, both those in current use and historical ones, in… …   Wikipedia