12

What does Mirah language offer over JRuby,Groovy and Scala?

dreftymac
  • 31,404
  • 26
  • 119
  • 182
Chiron
  • 20,081
  • 17
  • 81
  • 133
  • 1
    @pst: You think that languages being dynamic or static is such an overriding issue that nothing else is comparable? – JUST MY correct OPINION Nov 23 '10 at 02:14
  • 2
    @pst: No time to learn four languages :) , not to mention I doubt I will be able to smell the true scent of each language by having a quick sniff. – Chiron Nov 23 '10 at 02:37
  • @El Gusto I say "try", not "learn" (thoroughly) :-) In my experience, just a few days on a small "intro" project, lets me know if it's a language I want to pursue (e.g. I assign merit to it) or not. It doesn't mean the nuances are known or the code is idiomatic, but rather is enough to generally see "the big picture". –  Nov 23 '10 at 02:42
  • @JUST MY correct OPINION (awesome name, btw) - These questions come up quite a bit. Apples and oranges. It doesn't matter if it's a Red Delicious (ick!) or a Blood Navel. –  Nov 23 '10 at 02:43
  • @3lijandro: What is missing about the given answers? I would suggest either mentioning what is currently still missing IYHO or accept an answer, that would be nice. – soc Nov 28 '10 at 16:55

5 Answers5

12

Unlike full-featured languages, which come with their own libraries, Mirrah is more like a different "frontend" to the Java libraries.

Mirrah code does not depend on it's own environment (except the Mirrah compiler at compile time).

That's the main benefit: A different syntax for Java.

soc
  • 27,983
  • 20
  • 111
  • 215
9

According to an interview with Mirah's creator the point of Mirah (which means "ruby" in Javanese) is to create a high-performance variant of Ruby. Enough Ruby-like syntax to make it comfortable to work with, but still close enough to Java and JVM semantics so that it can run without the overhead of a big runtime layer on top of the JVM.

Choice quote:

Much of the benefit of Mirah over similar languages comes down to being so lightweight. In Groovy, Scala, JRuby, Clojure, or Jython, the minute you write "Hello, world", you've shackled yourself to a runtime library. In Mirah, "Hello, world" is just as terse as in JRuby, but has the added benefit of not foisting any dependencies on you; source file goes in, class file comes out, and that's it. I believe the JVM needs a new dependency-free language, and Mirah is my attempt to deliver one.

While JRuby's performance rivals or exceeds other Ruby interpreters, the fastest JRuby code still lags pure Java performance by an order of magnitude. While you can expect the performance of JRuby to improve with the 1.6 release, Mirah is an attempt to break through the performance ceiling and provide an option for programmers looking for execution speeds on par with Java code.

Community
  • 1
  • 1
Thilo
  • 257,207
  • 101
  • 511
  • 656
  • Thanks but still cloudy to me. – Chiron Nov 23 '10 at 02:38
  • 3
    Executive summary: "What does Mirah language offer over JRuby,Groovy and Scala?" According to them, performance. – Thilo Nov 23 '10 at 02:42
  • 7
    Scala is statically typed. Ruby/Groovy/Clojure adds a performance burden that Scala doesn't. Why is it in this list? – pedrofurla Nov 23 '10 at 02:52
  • 1
    @pedrofurla. I agree with you in that I do not agree that Scala should be in the list. Scala has a runtime library, but it probably does not add significant overhead performance-wise. – Thilo Nov 23 '10 at 02:59
  • 3
    @El Gusto: Well, when you write a `Hello World` in Scala, you get `6.496.110 scala-library.jar` (Scala 2.8.1), *plus* Java's own libraries (which, granted, put that file to shame). That Mirah does not bring any new libraries to the table is, indeed, interesting. – Daniel C. Sobral Nov 23 '10 at 11:32
  • 3
    @pedrofurla Actually, I didn't read anything about "performance" on their site. What they say is _No current JVM language addresses the aesthetic goals of Mirah without also introducing a runtime library, often of a prohibitive size._ Unless Thilo is going by a strange definition of performance. – Daniel C. Sobral Nov 23 '10 at 11:35
  • @Daniel: Hey, I am just quoting the Mirah team here. How often do I have to say "according to them" before it stops becoming "my" strange definition of performance? ;-) Adding another quote from the interview. – Thilo Nov 23 '10 at 12:32
  • 1
    @Thilo Ok, perhaps it was uncalled for, but that quote only refers to JRuby. I haven't seen any performance statements about _other_ JVM languages -- which would include Scala. Alas, any such statements would be incorrect, as Scala generates the same bytecode as Java. It does come with a library, however, which is a fair point they make (as in the text I quoted). – Daniel C. Sobral Nov 23 '10 at 13:05
  • 2
    Performance-wise, with the specialisation support available since Scala 2.8, Scala is able to produce *better* performing code than Java in a number of scenarios - by eliminating some boxing and unboxing of primitives. The cost of this is an increase in the size of compiled bytecode. – Kevin Wright Dec 21 '10 at 09:50
  • @pedrofurla Well, because it is my question. I didn't mention Clojure, so why it is in your list? – Chiron Sep 10 '14 at 11:30
  • Don't remember, it's been almost four years :) – pedrofurla Sep 10 '14 at 18:52
8

vs. Groovy

  • Syntax more familiar to existing Ruby/JRuby programmers
  • Statically typed

vs. JRuby

  • Statically typed

vs. Scala

  • Syntax more familiar to existing Ruby/JRuby programmers

The MAIN advantages are static typing (faster performance on the JVM and much easier interop with existing Java libraries) and a familiar syntax (if you come from Ruby).

When dependencies are a consideration (developing an android app, for example) then you shouldn't let this guide your language choice. Using a tool like Proguard will level the playing field.

If you're coming from Ruby, then Mirah is a good choice. If you're coming from Erlang or Haskell, then you'll want Scala. If you're a LISPer, then you'll want to take a look at Clojure.

If your only prior experience is Java then Shame on you! - and you should probably go for Scala - It's rapidly gaining a reputation as the heir apparent to Java, tool support is currently stronger and you'll be in a large community of others who made the same transition, so there are plenty of blogs/tutorials already available.

and Groovy? Groovy is almost never the right choice nowadays...

Kevin Wright
  • 49,540
  • 9
  • 105
  • 155
  • 3
    @seymour - James Strachan (creator of Groovy) sums it up nicely in his blog: http://macstrac.blogspot.com/2009/04/scala-as-long-term-replacement-for.html – Kevin Wright Mar 27 '11 at 18:11
5

I use Mirah everyday on Google AppEngine.

Here are my reasons to use Mirah:

  • no runtime library
  • very nice syntax
  • as fast as Java

Having Java under the hood is very helpful too:

  • solid typesystem
  • well documented
  • known solutions for common problems

I did some Groovy, lot of JRuby and none of Scala. If you know these, try Mirah. If not, I'd go with JRuby.

hakunin
  • 4,041
  • 6
  • 40
  • 57
  • Thanks for sharing a production story. – Chiron Dec 14 '10 at 18:08
  • Not sure I understand that logic: go with JRuby if you haven't done any Groovy or JRuby. If you have done them then go with Mirah. I'd challenge that! If anything, there's a strong argument for choosing Scala unless you have specific needs for Ruby syntax or dropping dependencies without using proguard. – Kevin Wright Dec 21 '10 at 09:57
  • I can recomend Ruby / JRuby to anyone beacuse it is easy to pick up and fun. – hakunin Dec 28 '10 at 13:01
  • @hakunin, Why not to go with Scala? I think that absence of std library is disadvantage. Because you have nice syntax, but still you have to use ugly Java library API. E.g. compare Collections.sort(l) { |a, b| a.c.compareTo(b.c) } to l.sort_by(&:c) – Alexey Aug 15 '11 at 06:45
  • any tutorial how to do that? ^^ (mirah with GAE) – Kokizzu Nov 18 '12 at 04:13
  • 1
    You can start here: http://code.google.com/p/mirah-on-gae/ (Disclaimer: I switched to Pythong for GAE, dunno what the state of Mirah is) – hakunin Nov 18 '12 at 17:24
-2

Mirah is just another rubyish syntax for java. IMHO not good at all. It knows nothing about generics, and also has poor tooling. Better try ceylon, xtend, scala, kotlin etc.
Mirah compiles to java classes (not sources anymore). Xtend compiles to java sources and so simpler to found out what it does under the hood. Ceylon and scala have their own stdlibs (nevertheless java interop is near to perfect in them both), not sure about kotlin. Kotlin is JetBrains' child and thus tied to IDEA.
JRuby I don't like too. It has too many bugs in java interop. And it also have too many reinvented wheels. I mean encodings (it does not use java strings and regexes but custom strings on top of raw byte buffers), IOs, exception handling, threads etc.
The only advantage of jruby is that it is ruby. Many ruby code will just work as it is.
Groovy OTOH does not reinvent the wheel, it uses well tested java libraries and just adds syntax sugar too them. Also groovy-java interop is great. It can generics. Threads, exceptions, strings, collections - are just java classes as they are in java.

guai
  • 780
  • 1
  • 12
  • 29