Hacker News new | ask | show | jobs
Is it possible/practical to program android in a language other than Java?
9 points by int_main_void 5630 days ago
So the quick and dirty back story of this question is that when I originally read Google's response to the Java lawsuit by Oracle, Google made reference to the fact that android doesn't use the Java virtual machine (it uses some other VM, but the name escapes me at the moment) and went on to say essentially that Java isn't the only language that can be used with the OS.

So when I read that it really got me thinking about how great it would be if I could program android apps without using Java. This is relevant to me because I know plenty of programming languages but I really haven't picked up Java or its predecessor C++ (technically I did make a basic android app essentially using what little I have learned of C).

Anyway its been a few months since I read that story and I have been digging around here and there (not too seriously) and have come across a few posts/blogs/ect affirming that it is possible and there is a tiny bit of documentation out there (for instance I found some python users out there using "Jythonroid")

Anyway the question is, is it really practical to program android in another language (yes I realize android utilizes XML in addition to Java) and if so which is the language(s) of choice?

Additionally, any bread crumbs that can be left leading to documentation would be very much appreciated.

Thank you.

Student

Daytona Beach, FL

5 comments

Depending on what you want to do there are some options.

The one that's been around longest but the most limited is the ASE (Android Scripting Environment) http://google-opensource.blogspot.com/2009/06/introducing-an...

Using the ASE you can create some simple programs to do small tasks.

If you're looking to build a full app you're probably going to be looking at either working through Java, or if you're on Gingerbread you can use C++. Previous versions of Android allowed for C++ libraries being linked to your apps but had no way to access the APIs for creating graphical interfaces. That's now changed so I recommend you look into the SDK and NDK if you're really serious about building on Android. http://developer.android.com/sdk/ http://developer.android.com/sdk/ndk/

The only other option that I know about is that the Mono framework is being ported to android (.NET framework port). So if you know C# or any other .NET language you may be able to start there, although I think it's currently in closed beta. http://monodroid.net/

Android uses the Dalvik virtual machine, which is a clean-room implementation and different to JVM. Basically the .dex files are about 45% in size of compressed JAR files. Dalvik has been optimised for small RAM & slow CPU (compared to recent notebooks and desktops).

If you Google "Dalvik VM" you'll find lots of interesting information, too many to list here. There's a Google presentation which is very good.

So the answer to your question, is that so far, AFAIK, there is no compiler that directly generates Dalvik executables into .dex files. Currently, you need a Java .class file or a .java file and get it translated into a .dex file. But a retargetable compiler, like llc, could be customised to generate .dex files directly. An interesting project.

I hate Java, but am using it for Android to take full advantage of the platform.

However, as an Actionscript guy I am curious about using AIR to write Android apps. Specifically, if I did this, would I be able to offer upgrades to native apps writen in Java down the road? Or would the Java versions have to be installed as separate apps rather than upgrades?

I wrote a couple of test android apps in scala and was very pleased with the results. Scala is a huge improvement on java but gives you nearly the same execution speed which is particularly important on devices with limited CPU and RAM. There's a plugin for sbt (a scala build tool) that will assemble your .apk and upload it to the emulator or a device.
Thanks for the links. It looks like scala is the most viable option currently, but a few others exist as well. I will probably doodle in scala later this week and see what I can make of it.