Mirah on the NXT

I’m working on a few things that require a bit more code that what I’ve done so far, but I find it to cumbersome to write so much code using NBC, NXC or NXT-G. Then I found Lejos.

Lejos is a Java Virtual Machine for the NXT, and it replaces the standard firmware. While Java is a marginally nicer language, the major win is in the packages.

Lejos comes with a lot of packages that contain useful code for doing common things, neatly organized by names like lejos.navigation.Navigator or java.util.Map.

The only problem with Java is that it’s verbose. Compare a simple program that prints “Hello world!” written in Ruby, and in Java.

You might wonder why Ruby is suddenly involved. It’s because of Mirah, which is Ruby syntax for Java classes.¬†You could thus run the linked Ruby code, but you are actually using java.lang.System.out.println.

This means that if you need to know how to write something, google for the Ruby solution. If you want to know which classes to use, look for the Java solution. (classes are like hierarchical  collections of words, more on that later)

To make this all work with the NXT, you first need to instal Lejos.

To install Mirah, you also need to install jRuby, afterwards you can just run

jruby -S gem install mirah

Stay tuned for for some Mirah code for the NXT. I might also tell you more about classes.

This entry was posted in Uncategorized. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.


  1. NeXT-Generation
    Posted May 29, 2012 at 12:14 pm | Permalink

    Sounds good. Can’t wait to see what you come up with!

  2. Markus Kirschner
    Posted July 7, 2012 at 2:36 pm | Permalink

    what an amazing idea. Could you please post the commandline instructions to compile a Mirah sourcefile to LeJOS Java?
    Thanks in advance!

  3. pepijndevos
    Posted July 7, 2012 at 8:25 pm | Permalink

    Ok, so basically you do
    mirahc --bootclasspath /mirah/classes.jar MyClass.mirah
    and then upload it using nxj. Not at my computer now, but that’s the gist of it.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

  • Get new ideas and models per email

    * = required field
  • Categories