Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Use Mirah rather than Java for controller code: check out my new library! (http://www.chiefdelphi.com/forums/showthread.php?t=109460)

Jeremy_Mc 10-11-2012 11:35

Use Mirah rather than Java for controller code: check out my new library!
 
Hello!
I'm hoping to get involved with FIRST again this year as a mentor after taking a few years off, but I figured in the mean time, I'd hack something out to help out everyone. :)

I just released Fresno, a framework that does two things:
  • Generates project folders for Mirah-driven FRC projects and...
  • (eventually) offer a number of convenience classes for making writing FRC code easier

The framework is meant to make it possible to use Mirah (a language that compiles down to Java or JVM bytecode with no runtime overhead at all) to write your controller code rather than Java or C++. Why would you want to do that you might ask? Well, here's a trivial example:

Code:

// Java
public class Excellent {
  public void robotics() {
    java.lang.System.out.println("ROBOTS.");
  }
}

# Mirah
class Excellent
  def robotics
    puts "ROBOTS."
  end
end

As you can see, it's a little cleaner and friendlier (partially thanks to the not-really-demoed-here type inferencing that makes is so you don't have to put type declarations all over the place where a good compiler should be able to figure it out), and adds a few new features like closures:

Code:

arr = [1,2,3,4]

arr.each do |elem|
  puts elem
end

...and more (including some really nice metaprogramming features that make it easy to abstract a lot of complex logic away and some dynamic type handling).

So, if you're interested, head over to my GitHub repo page for the project and fork it/clone it/install it. It's still very early in its development, so the install process could be a little arduous and there are very likely looming bugs. I plan to make the install a little smoother soon, but if you're a brave early adopter, then please head over and check it out. I'm also working on a Mirah tutorial since the documentation for it is severely lacking. If you're wanting to try it out now, poke around on GitHub at the various Mirah projects for some examples.

One thing that would be a huge help: I actually don't have a cRIO board in my possession (yet? Anyone want to lend/sell me one for testing this stuff? :)), so while the code appears to build and such, I don't know if it *actually* works on the board. So if any of you get a chance to check it out and try it on a real board, let me know if it works like I think it should. :) If it breaks (or anything else), file an Issue on the GitHub repo so I can get to work on fixing it.

RyanCahoon 11-11-2012 09:43

Re: Use Mirah rather than Java for controller code: check out my new library!
 
What capabilities will your framework offer beyond those of WPIlibJ?

Quote:

Originally Posted by Jeremy_Mc (Post 1193480)
The framework is meant to make it possible to use Mirah (a language that compiles down to Java or JVM bytecode with no runtime overhead at all) to write your controller code rather than Java or C++.

The resources I could find say that Mirah is still in development. Is it a stable enough language to use for FIRST? I'd rather not have to wait 2 weeks for a bug fix during the 6 week build season.

Have you checked that Mirah can be compiled to Java ME CLDC? I know a lot of other JVM-targed languages use reflection APIs behind the scenes that aren't included with the lightweight JVM that runs on the cRIO.

Jeremy_Mc 11-11-2012 10:23

Quote:

Originally Posted by RyanCahoon (Post 1193611)
What capabilities will your framework offer beyond those of WPIlibJ?

It actually uses WPIlibj but through Mirah rather than Java proper. The extensions I'm adding will mostly be for adding nice Mirah syntax over the Java methods rather than replacing WPIlib methods totally.

Quote:

Originally Posted by RyanCahoon (Post 1193611)
The resources I could find say that Mirah is still in development. Is it a stable enough language to use for FIRST? I'd rather not have to wait 2 weeks for a bug fix during the 6 week build season.

It's been in development for some time. It's not perfect but they are rather responsive to fixing bugs! :) I think it's definitely in a usable state. The good thing is that if you decide that it isn't working for you, you can compile it down to Java source files and switch to Java.

Quote:

Originally Posted by RyanCahoon (Post 1193611)
Have you checked that Mirah can be compiled to Java ME CLDC? I know a lot of other JVM-targed languages use reflection APIs behind the scenes that aren't included with the lightweight JVM that runs on the cRIO.

That was a concern of mine, too, so I double checked with the creator of Mirah. He said it should work great on J2ME since it compiles down to simple vanilla Java rather implementing a runtime on top of it with weird reflection and generics.


All times are GMT -5. The time now is 02:15.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi