mirah – PullMonkey Blog http://pullmonkey.com Sun, 13 Nov 2011 04:47:47 +0000 en-US hourly 1 https://wordpress.org/?v=5.6 Hello Android – Pindah (with Mirah) Application http://pullmonkey.com/2011/11/13/hello-android-pindah-with-mirah-application/ Sun, 13 Nov 2011 04:38:08 +0000 http://pullmonkey.com/?p=57638 Did you install the Android SDK / JDK, etc?  If not, start here - http://developer.android.com/sdk/index.html.
If you're running 64-bit like me, make sure to install the ia32-libs, since the SDK is 32-bit.

This is completely based on the Hello Android tutorial - I didn't really do a whole lot, but the hope is that this will help get some more ruby devs into android development with a simple how-to.

Step 1 - Setup RVM with jruby

Note: RVM is awesome, if you don't use it or don't know about it - read more here.

rvm install jruby
cd /path/to/your/android/pindah/mirah/project/dir/
# using your .rvmrc will trigger `rvm use jruby` when you cd into your project dir.
echo "rvm use jruby" > .rvmrc
# this will make sure your .rvmrc is working, you should then be able 
# to use rvm info and see jruby
cd .

Step 2 - Install the mirah and pindah gems

# too easy
gem install mirah pindah

Step 3 - Create your first pindah app

pindah create com.example.android.hello_world
cd hello_world

Step 4 - Create your activity - HelloAndroid.mirah

# from your project dir and inside your pindah app dir 
<editor> src/com/example/android/hello_world/HelloWorld.mirah

This is the code I used:

Step 5 - Setup your AndroidManifest.xml file

This is where you define your app, version, name, etc, but more importantly for this example - what activity will handle your main intent.
Mine looks like this:

Step 6 - Install to your device

# make sure a device is recognized  ... 
# and make sure adb is in your path (platform-tools in the SDK)
adb devices
rake install

]]>
Playing with Mirah http://pullmonkey.com/2011/11/10/playing-with-mirah/ http://pullmonkey.com/2011/11/10/playing-with-mirah/#comments Thu, 10 Nov 2011 06:14:37 +0000 http://pullmonkey.com/?p=57622 Mirah (formally duby) is pretty freaking cool.   Plans are to scrap java and use mirah for future android development, we'll see.  Here's a rough example of some pretty basic mirah.

To get started, you'll need jruby and the mirah gem:

rvm install jruby
rvm use jruby (or put in your .rvmrc)
gem install mirah

Then create an example:

puts "hello world!!"
500.times do |x|
  puts x
end

Time in ruby:

time ruby test.mirah

...
=> .457s

Compile to Java and time:

mirahc test.mirah
time java Test

....
=> .081s

Less than 1/5 the time and it compiles to Java ... neat 🙂

mirahc -j test.mirah

// Generated from test.mirah
public class Test extends java.lang.Object {
  public static void main(java.lang.String[] argv) {
    int __xform_tmp_1 = 0;
    int __xform_tmp_2 = 0;
    int x = 0;
    java.io.PrintStream temp$1 = java.lang.System.out;
    temp$1.println("hello world");
    __xform_tmp_1 = 0;
    __xform_tmp_2 = 500;
    label2:
    while ((__xform_tmp_1 < __xform_tmp_2)) {
      x = __xform_tmp_1;
      label3:
       {
        java.io.PrintStream temp$4 = java.lang.System.out;
        temp$4.println(x);
      }
      __xform_tmp_1 = (__xform_tmp_1 + 1);
    }
  }
}
]]>
http://pullmonkey.com/2011/11/10/playing-with-mirah/feed/ 1