ArticleslgStudy

computer science

Mirah (programming language)

Mirah (programming language) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Mirah (programming language) rather than just read about it. In short: Mirah (formerly Duby) has been a programming language based on Ruby language syntax, local type inference, hybrid static–dynamic type system, and a pluggable compiler toolchain. 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, idiomatic JVM bytecode." The word mirah refers to the gemstone ruby in the Javanese language, a…

Key takeaways

  • Mirah (programming language) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Mirah (programming language) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Mirah (programming language) from memory before moving on to harder problems.

Reference excerpt

Mirah (formerly Duby) has been a programming language based on Ruby language syntax, local type inference, hybrid static–dynamic type system, and a pluggable compiler toolchain. 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, idiomatic JVM bytecode." The word mirah refers to the gemstone ruby in the Javanese language, a play on the concept of Ruby in Java.

History 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 compiling. In this context, "native" meant mainly the Java virtual machine (JVM), but Mirah has been designed around the possibility of having alternative backends for other object-oriented runtimes like the Common 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 other JVM languages) and to suffer no performance penalty (which precludes writing in Ruby). Early versions of Mirah (then Duby) focused mostly on mathematical performance, where dynamic 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.

Design Mirah is mostly a pluggable compiler toolchain. The main elements of the chain are:

A parser, based on JRuby's parser, that emits a Ruby abstract syntax tree (AST) A transformer that converts the Ruby AST into a Mirah AST A type inferrer that decorates the Mirah AST with appropriate typing information for the target backend A backend code generator 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 language plug-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 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 also. 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.

Syntax 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: 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:

Status As of 2012, Mirah is under development, but some developers are using Mirah for production applications of limited scope.

Frameworks

Dubious Dubious is a project for running Mirah on Google App Engine. It provides a way to build apps in Mirah, with conventions familiar to developers using Ruby on Rails and Sinatra. Since everything is compiled ahead-of-time, Mirah applications have none of the initializing costs associated with JRuby. Dubious supports ERuby (ERb) and has a simple datastore adapter that uses a syntax similar to Datamapper.

See also

List of JVM languages

References

External links Official website Introduction to Mirah by Charles Nutter - Dr. Dobb's, March 25, 2011 Breaking the Rules - Making Java Fun with Mirah - Roja Buck, Mar 20, 2011 A Blend of Java and Ruby - The Mirah Language - InfoQ, July 27, 2010 Mirah brings Ruby niceties to Java - InfoWorld. July 23, 2010 "Mirah: Taking Performance to the Next Level with Java's Ruby" - O'Reilly Media, July, 2010 Introducing Duby, Ryan Brown "Ruby Mutants Presentation", Railsconf 2009 Dubious framework Video presentation: JRuby, Duby, and Surinx: Building a Better Ruby Video Lightning talk: Rails Underground 2009 - Charles Nutter on Charles Nutter - Duby and Juby Languages What does Mirah offer over JRuby, Groovy and Scala?

Worked examples

Example 1 — a first encounter with Mirah (programming language)

Start with the simplest possible case. Write down what Mirah (programming language) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Mirah (programming language) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Mirah (programming language) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Mirah (programming language)

In research
Mirah (programming language) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Mirah (programming language) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Mirah (programming language) is common in secondary-school and first-year university syllabi. It links to neighbouring topics JVM programming languages, Java programming language family, Object-oriented programming languages, so understanding it makes those chapters shorter.
In everyday life
Look for Mirah (programming language) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Mirah (programming language)” →

How to study Mirah (programming language) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Mirah (programming language) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Mirah (programming language) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Mirah (programming language) in simple terms?

Mirah (formerly Duby) has been a programming language based on Ruby language syntax, local type inference, hybrid static–dynamic type system, and a pluggable compiler toolchain. Mirah was created by Charles Oliver Nutter to be "a 'Ruby-like' language, probably a subset of Ruby syntax, that [could]…

Why does Mirah (programming language) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Mirah (programming language)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Mirah (programming language).

Tags

  • JVM programming languages
  • Java programming language family
  • Object-oriented programming languages
  • Programming languages created in 2008
  • Scripting languages
  • Software using the Apache license
  • Statically typed programming languages

Keep exploring