Stuff in Ruby that is/isn't supported, or is different
=begin / =end
Rib Rdb writes: "The new parser doesn't support this". Use single line comments instead
The object model
The ruby object model is not the same as the java object model. The difference people seem to come up against most often is in static methods. Rib Rdb again: " Static and instance methods are all lumped together, so you can't have an instance method with the exact same name/arguments as a static method. I believe the same thing goes for fields"
You may also run into inheritance issues: see e.g.
http://groups.google.com/group/mirah/msg/5a8923432da594ed
Extending an existing Java class
is not currently supported, but is on the roadmap:
http://groups.google.com/group/mirah/msg/b3d5b34f9be0ecf8
optional args : not supported, use method polymorphism instead
mirah doesn't do optional method args in the ruby way. However, you can (like java) have have multiple methods with the same name and different arguments
HEREDOC is supported
http://groups.google.com/group/mirah/browse_thread/thread/b9cec92232187890
the ruby standard library
The Ruby standard library is by and large not part of Mirah: try using the equivalent Java functionality instead where available. For example,
"You can use Collections.sort(list) {|a, b| ... }
There's also Arrays.sort, but I don't think we support converting arrays to Object[], so you'd have to use Collections.sort(Arrays.asList(array)) {...} "
http://groups.google.com/group/mirah/msg/d6b0a971d61c17ae
Stuff in Java that is/isn't supported
interfaces
are there.
http://groups.google.com/group/mirah/browse_thread/thread/6832ae248bf41bca#
long integers
The L suffix for literal numbers is not supported but will be
http://groups.google.com/group/mirah/msg/3d03b1be06277b5e
parameterized types (generics, type parameters)
are not suported "but that really shouldn't matter; since the JVM erases generic types at runtime" - Charles Nutter
http://groups.google.com/group/mirah/msg/59b7a047fc854b93
static fields
"Someone asked me today if Mirah supported static fields, and I had forgotten the answer. So I poked around and remembered that instance vars in static methods end up being static"
http://groups.google.com/group/mirah/browse_thread/thread/3a35eeed574e5310#
Annotations
"Yes. We use $ instead of @. For example $Deprecated def foobar; end The source code compiler doesn't support annotation values, but the bytecode backend should support string, class, and annotation values, as well as arrays of those types. We use square brackets instead of parens around the values: "
http://groups.google.com/group/mirah/browse_thread/thread/37705643114f5d4a#
Exceptions
"We use ruby's syntax for exceptions (except we don't support retry or catch/throw). "
"If you want to declare which exceptions a method throws you use the throws macro [...] This is only required if you're using the .java backend though as the .class backend doesn't check exceptions."
[ editorial interjection: praise be unto (Allah|the Lord|the FSM|Linus)! Exception checking was always one of java's uglier misfeatures ]
final and void
"in java final means the variable can't be modified after it's initialized, and you need to use it for all variables you access in a java closure. Mirah has mutable closures so we don't have that restriction, and there's no way to mark something final. "
"If you're subclassing a java class or implementing an interface with a void method we should be able to infer that automatically. The only time you need to specify void is if you want force a method to return void."
packages
I have tried 'package' keyword at top of the mirah script but that does not work. Is it possible to compile mirah script into a package at this stage of development?
"Right now the package comes from the directory of the file. So if you run mirahc foo/bar.mirah you get the class foo.Bar"
http://groups.google.com/group/mirah/browse_thread/thread/7d76cdf6b99f9ab2#
Stuff that's unique to mirah
Macros
The example didn't work when I cut and pasted (may be obsolete,or I may be misunderstanding the contexts in which macros can be used). But you dear reader are probably smarter than me, so try it yourself
http://groups.google.com/group/mirah/browse_thread/thread/c6c4df3f6a40d05e# http://groups.google.com/group/mirah/browse_thread/thread/4960d2b5d2d98861#
Android
Garrett (on github) is an example Android app written in Mirah.
Mirahndroid (working name, may soon be called Pindah) is a script originally derived from Garrett which generates a skeleton android project in mirah
http://groups.google.com/group/mirah/browse_thread/thread/8c0f5f320e85e357
Bugs and troubleshooting
InferenceError
InferenceError usually means "something went wrong and we don't have a more specific error message". Could be pretty much anything
backends out of sync
The jvm backand and the java source backend are sometimes out of sync: certain stuff might work in one but not the other
java.lang.VerifyError
Rib Rdb writes "Any time you get a java.lang.VerifyError you've found a bug in mirah. Unfortunately as you found the JVM isn't very helpful in explaining what that bug is. If you set the environment variable BS_CHECK_CLASSES=true and recompile the file you should hopefully get a better description of the problem."
Mirah now seems to support optional args: