

The Mirah Language: bringing modern features to the JVM without runtime overhead - technomancy
http://drdobbs.com/java/229400307

======
headius
I forgot to show one of the coolest features of Mirah...it can output Java
source too: <https://gist.github.com/888001>

The original goal for this was to allow Mirah to be used in places where Java
source is required, like GWT apps. We've kept it going over the years (thanks
to Ryan Brown, my co-conspirator).

~~~
thasmin
Android is an exciting use case for Mirah. The other JVM languages run into
the runtime library and performance problems mentioned towards the beginning
of the article.

~~~
bitsai
Kawa Scheme is another JVM language that works well on the Android.

3-part tutorial on how to write Android apps in Kawa:
[http://androidscheme.blogspot.com/2010/10/introduction-to-
an...](http://androidscheme.blogspot.com/2010/10/introduction-to-android-app-
development.html)

------
wccrawford
I looked into using Mirah for Android programming a while back. I took a 3D
tutorial for Android (in Java) and tried to do exactly the same in Mirah.

What I found was that it seemed to be (mostly) possible, but there was NO
documentation on how to do most things. With someone's help, I got the
tutorial working, except for 1 last bit at the end that wasn't really
necessary yet. I never did figure out how to do that bit.

This is the tutorial: [http://www.droidnova.com/android-3d-game-tutorial-
part-i,312...](http://www.droidnova.com/android-3d-game-tutorial-
part-i,312.html)

The part I never got working was the 'queueEvent' bit of the 'onTouchEvent'
bit. Without queueing it, I could get it to work, but I could never figure how
to queue it like that.

My sources as I left them: <https://github.com/wccrawford/Hello-Mirah--
Android>

Without any documentation or real info out there on Mirah, it was incredibly
frustration just to get that far.

I realize it's a new language, but I can't recommend its use at this point. It
needs to mature and gather a community before it's worth investing serious
time in.

~~~
Roboprog
It looks promising, but I want a few things first as well:

* docs (as mentioned)

* some kind of javadoc / rubydoc mechanism (perhaps there is?)

* a NetBeans plugin

* a pony

OK, maybe I can get by without the last one :-)

~~~
headius
Docs...yes, we're getting there. Not all the languages features are even
documented because they were added very quickly. It's coming along.

I've been thinking about a MirahDoc format. I think we could pretty much do it
like JavaDoc. Potentially even make it work with Doclets.

There is an old NB plugin based on the Ruby plugin, but I doubt it works now.
We'd love to have help here. The plugin is on github:
<https://github.com/mirah/mirah-netbeans-plugin>. Of course we'd like help
supporting Eclipse and IntelliJ too.

------
jameskilton
And the best thing about Mirah? It's written in JRuby.

Charles Nutter is insane. I've got to find a way to use this myself. Maybe for
his encore he'll rewrite JRuby in Mirah, just to show Mirah is everything Java
is and more. Or maybe the world will explode, who knows.

~~~
technomancy
> Maybe for his encore he'll rewrite JRuby in Mirah

Actually, that was part of the motivation behind Mirah; Rubyists don't want to
contribute to the parts of JRuby that are implemented in Java.

~~~
mambodog
Well, what would you expect from people who title themselves 'rubyists'? As
opposed to 'programmers', 'web developers' or anything meaningful at all.

------
amadiver
Pretty neat. Mirah is to Java as CoffeeScript is to JavaScript?

Looks very similar to ActionScript 2, with shades of Scala. Really neat
looking language.

Anyone know where the `param: Type` (i.e., parameter name colon type)
convention came from? I've seen it more frequently lately, and I wonder if
it's easier to parse than Java's `Type param` (or my favorite: `param Type`)?

~~~
headius
I actually officially asked Jeremy Askenas if I can use the phrase "Mirah is
the Coffeescript of Java". He gave me his blessing.

The param:type notation I largely just stole from Scala, but it seems (in my
novice opinion) easier to parse as well. It also fits better with optional
type declarations, which we have in the case of interface impl or class
extension (easier to omit syntax on the RHS than on the LHS for a typical
parser).

~~~
headius
And oops...that's Ashkenas. Sorry, Jeremy :)

------
donw
I started playing with Mirah last weekend, and I'm probably going to use it in
my next project. Native Java speed, Ruby syntax, and JRuby interop are a hard
feature list to beat.

------
chuhnk
One of the things that I extremely love about this is the fact that it
compiles down to almost identical java bytecode and then can be run with the
java command. The fact that performance is on par with java. That it is
basically statically typed ruby on the jvm. In my opinion its what jruby
should have been. Its absolutely brilliant and a testament to how languages
should be written on the jvm. I think one of the key points as said is to
limit overhead in comparison to java.

Has anyone written anything in mirah thats been deployed? I assume it can be
built pretty much in the same way as any java project.

------
6ren
Java without ceremony ( _I don't know, code casual_?)

But last time I tried it, there was massive compile time overhead (30 seconds
for hello world, on a eee PC). Has that changed? I'm possibly getting it
confused with a bunch of JVM languages that I tried out at the same time.

~~~
tomjen3
Thats often the case with new languages. I remember it took longer than that
to compiler Hello World in Scala, but today that is pretty fast.

~~~
headius
We've slowly moved more and more of Mirah into Mirah code as well, which will
help performance over time. Currently almost all of Mirah is written in
(J)Ruby, with according startup and performance overhead. Great for
prototyping, and great for extending (we will probably always allow defining
language features in Ruby) but not great for quick startup and fast execution.

------
riobard
The checklist for Scala:

\- Performance equivalent to Java for equivalent code

Pass.

\- No language-imposed runtime library

Failed. 5mb runtime lib.

\- No more (or not much more) complicated than Java

It depends. For some, Scala feels much more streamlined than Java. For others
(esp. those used to dynamic languages), the type system is a huge pain.

\- Beautiful

Certainly much more beautiful than Java.

\- Perfect integration with JVM libraries

Use existing JVM libs without change.

\- Extensible

Major language features such as actors are all libraries. Very easy to embed
DSLs.

~~~
headius
Scala is a great language, but the requirement that I ship Scala's libraries
if I want to do thinks the Scala way is a nonstarter for the use cases I have.
Yes, you can Proguard a lot of that away, but if I use Scala's collections or
other libraries, I'm still stuck adding a runtime lib.

As far as the others go...I don't disagree. Perfect integration with Java is
perhaps a bit debateable, since you can't overload constructors, can't define
real static methods Java can see, and so on. But those are minor items.

I don't intend Mirah to be a Scala-killer either. Scala is more of a platform
now than just a language, and if you're on that platform, you have my
blessing. If, however, you just want something to replace javac everywhere you
use Java today, I believe Mirah is a better fit.

~~~
riobard
You are right. It really depends on use cases. In many scenarios, a 5mb lib is
just another dep that build tools such as sbt will handle for you. In many
others, 5mb overhead to a 500kb mobile app is obviously overkill.

My use case is fine with Scala: no deployment issue, no Java legacy other than
using a few libs, and everything else is fresh in Scala. So far I'm very happy
with the choice. FP makes things really compact.

I like Mirah for the fact that it can generate Java source code (vs. JVM
bytecode). I would imagine there are many cases Java compatibility down to the
source code level would be desired.

Anyway, good job!

------
tszming
Neat and interesting, I strongly prefer Mirah more than Scala to be the "next
Java"

~~~
ohhmaagawd
gimme optional dynamic typing and I'm sold

~~~
michaelcampbell
I believe it's in there, no? (Requires the java 7 runtime, if memory serves?)

~~~
jshen
Can you link to an example or something?

~~~
headius
Here's the example from Mirah's repo:
[https://github.com/mirah/mirah/blob/master/examples/dynamic....](https://github.com/mirah/mirah/blob/master/examples/dynamic.mirah)

It does require Java 7 and there's no plans to make it work on Java 6-. Unlike
the rest of Mirah, this feature (if you use it) _does_ require a runtime
library, since Java 7 / invokedynamic do not ship anything builtin for
choosing a target Java method. We use Attila Szgedi's "dynalink" project,
which provides a default dynamic linker based on Java language specification
method selection rules.

Long story short: yes, Mirah can support dynamic dispatch as well, but it
needs a little bit of runtime library to support that.

------
baltcode
Is there something similar for Pythonistas? i.e., something with python-like
syntax, static and duck typing, and performance that of equivalent Java?

~~~
chc
Ruby syntax is already really similar to Python syntax. Significant
indentation is the biggest difference. I actually made a prototype Ruby with
significant indentation a la Python and I think most people would have
mistaken it for Python at a glance.

------
jshen
Is there an example somewhere that involves compiling more than 1 file?

~~~
headius
You should be able to just specify a list of files to the compiler. They
should sort themselves out.

