Friday, January 13, 2012

Scala + Android = Angry Monkey

Not working the last couple of months has afforded me the opportunity to buy a house, get married, move in, get married again, and most importantly, learn Scala. For the sheeple, it's a programming language that integrates seamlessly with Java, the primary language with which I've developed software for most of my career.

Some background to make your brain hurt... To execute Java code, it must first be "compiled"; that is, converted into the binary form of 1s and 0s, "bytecode", that a computer can understand from the 'source' text I type. Scala integrates itself by also compiling into Java bytecode, making it transparent to the computer executing the program that it's actually a Scala program.

Which leads us to the brain fart that Android made in its core design. The Android platform, which can run Java, does things a bit differently. After watching my simple Scala program bleed memory like an artery just trying to startup on the Android emulator, I did some research. It seems Android compiles Java into and runs off of DEX bytecode, which it creates from the Java code just like standard compilation.

Does the DEX compiler know how to interpret Scala source files? Of course not. Rather than working from Java bytecode to generate the corresponding DEX bytecode, they reinvented the wheel of compilation and basically screwed me. Having written some elegant Scala code, I now must reinvent my own wheel in Java just to run it on the Android platform.

To add insult to injury, the googling turned up suggestions of Android commands to generate a magical script that could "DEX" the Scala files. What do these commands do? Start up Eclipse, my development environment, and then hang. Sigh.

Ninja Code Monkey says: You suck, Android.

2 comments:

  1. I thought this blog was going to be about bad drivers . . . kidding of course!

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete