| Mirah | |
|---|---|
| Paradigms | Object-oriented,imperative |
| Designed by | Charles Oliver Nutter |
| Stable release | 0.2.1 / September 26, 2016; 9 years ago (2016-09-26) |
| Typing discipline | static, with dynamic features,strong,inferred |
| Platform | Java virtual machine |
| OS | Cross-platform |
| License | Apache License 2.0 |
| Website | https://mirah.org/ |
| Influenced by | |
| Ruby,Java,Boo | |
Mirah (formerlyDuby) has been aprogramming language based onRuby language syntax, localtype inference, hybrid static–dynamictype system, and apluggable compilertoolchain. Mirah was created by Charles Oliver Nutter to be "a 'Ruby-like' language, probably a subset of Ruby syntax, that [could] compile to solid, fast, idiomaticJVMbytecode."[1] The wordmirah refers to the gemstoneruby in theJavanese language, a play on the concept of Ruby in Java.[2]
To foster more participation in theJRuby project from Ruby community members, Nutter began to explore the possibility of presenting Ruby syntax, but with astatic type model and direct-to-native compiling. In this context, "native" meant mainly theJava virtual machine (JVM), but Mirah has been designed around the possibility of having alternativebackends for other object-oriented runtimes like theCommon Language Runtime (CLR) of the.NET Framework. The language needed to look and feel like Ruby, and to introduce no new library dependencies into JRuby (which precludes most otherJVM languages) and to suffer no performance penalty (which precludes writing in Ruby).
Early versions of Mirah (then Duby) focused mostly on mathematical performance, wheredynamic programming languages often pay the highest cost. Since then it has evolved into a full JVM language, with several users and real-world applications using it for core components.
Mirah is mostly a pluggable compiler toolchain. The main elements of the chain are:
Of these phases, only the last two need specific knowledge of the eventual target platform. This makes Mirah suitable for many backends, and also makes it possible to write languageplug-ins 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 emits nearly the same instructions as standardjavac compilers.
Because Mirah is just a compiler, it ships nostandard 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.
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 typedeclarations refer to JVM classes, primitives, and interfaces.
Mirah is primarily a statically-typed language, but support is in development to allow dynamic typing also. The mechanism is similar to that provided inC# 4, with a specialdynamic type indicating all dispatches against thatvariable's value should be done dynamically. Dynamic type support is currently planned only forJava 7 and higher, using the newinvokedynamic bytecode.
The syntax of Mirah is largely the same as the syntax ofRuby, but with a few modifications to support static typing:
deffoo(a:String,b:int)
interface used to specify a JVM-style interface.Outside of these differences, Mirah code generally looks like Ruby code:
deffib(a:int)ifa<2aelsefib(a-1)+fib(a-2)endend
As of 2012[update], Mirah is under development, but some developers are using Mirah for productionapplications of limited scope.
Dubious is a project for running Mirah onGoogle App Engine. It provides a way to build apps in Mirah, with conventions familiar to developers usingRuby on Rails andSinatra. Since everything iscompiled ahead-of-time, Mirah applications have none of theinitializing costs associated with JRuby. Dubious supportsERuby (ERb) and has a simple datastore adapter that uses a syntax similar toDatamapper.