Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

I have a software problem that fits the functional approach to programming, but the target market will be on the Android OS. I ask because there are functional languages that compile to Java's VM, but Dalvik bytecode != Java bytecode.

Alternatively, do you know if the dx utility can intelligently convert the .class files generated from functional languages like Scala?

Edit: In order to add a bit more helpfulness to the community, and also to help me choose better, can I refine the question a bit?

  • Have you used any alternate languages with Dalvik? Which ones?
  • What are some "gotchas" (problems) that I might run into?
  • Is performance acceptable? By that, I mean the application still feels responsive to the user.

I've never done mobile phone development, but I grew up on constrained devices and I'm under no illusion that there is a cost to using non-standard languages with the platform. I just need to know if the cost is such that I should shoe-horn my approach into default language (i.e. apply functional principles in the OOP language).

share|improve this question

closed as too broad by Snowman, gnat, MichaelT, durron597, Dan Pichelman Jul 10 at 19:57

There are either too many possible answers, or good answers would be too long for this format. Please add details to narrow the answer set or to isolate an issue that can be answered in a few paragraphs.If this question can be reworded to fit the rules in the help center, please edit the question.

I've updated the question. Thank you @geekosaur for your initial answer. That was starting information that I was looking for. –  Berin Loritsch Mar 30 '11 at 12:12
I've heard whispers on Haskell cafe of people doing this with FFI + Haskell + Courage. I believe there is a library on github/hackage for it –  jozefg Jun 20 '13 at 16:25

5 Answers 5

up vote 7 down vote accepted

There's a blog post by Christian Neukirchen called Programming for Android with Scala that shows how to build Scala programs for Android. It looks like dex can handle Scala, but you need to use a tool like ProGuard to cut the Scala class library down to size because dex will otherwise import the entire Scala runtime.

There's also some ongoing work on Android programming with Erjang and Clojure.

share|improve this answer
It appears that just about all the options you gave have serious performance penalties. That tells me that the options aren't really mature enough for prime time just yet. Maybe in another year? –  Berin Loritsch Mar 30 '11 at 12:13
As long as you don't use large parts of scala's class library, there should not be any significant performance penalty. Also, you can automate the whole process with maven. –  Kim Mar 30 '11 at 13:15
@Berin: I think the future is not using JVM-targeting languages — dex is after all optimized to deal with not just Java bytecode but also Java's bytecode conventions (you'll see some discussion of this in the links I provided earlier) — but targeting the Dalvik VM directly. Conceivably that could end up being faster than the Java-dex route. –  geekosaur Mar 30 '11 at 17:33
And for those wondering: the Dalvik VM bytecode is documented: opcodes, instruction formats. I see some possibilities for peephole optimizations not possible by targeting the JVM right away, let alone smarter optimizations using the Dalvik architecture directly. –  geekosaur Mar 30 '11 at 17:37
@Kim, the article I found said the performance problem was in the differences between the class loading algorithms for Java and Dalvik. If I stay away from the dynamic language features of Scala, I should be able to avoid the class loading issues. That same issue plagued the other options. It's still all rather new right now. I still may end up trying it out on this project--it's a proof of concept any way. –  Berin Loritsch Mar 30 '11 at 17:59

Kawa is a lovely but little known variant of Scheme that has existed quietly for many years and runs on both the JVM and Dalvik, natively. Therefore, similar to Mirah, its output includes no extra VM and only includes explicitly imported libraries. Kawa has lots of standard macros (including some specific to Android APIs) that make for a nice clean syntax (assuming one is not averse to parentheses), and adds some tasty goodies on top of Scheme, like "promises" (lazy eval and futures in one). The language is quite robust and well-documented, and has been actively maintained and evolving since the early days of Java.

The Java Advent Calendar summarizes Kawa's merits with some informative examples and links.

share|improve this answer
Wow, thanks for pointing me towards Kawa! I've been itching to do some non-Java Android development and this looks really promising. –  Evicatos Jun 20 '13 at 17:14

Beside scala I may suggest you to have a look on mirah on android, here are some details:

So what makes this approach 'better' than the other languages? Mirah is a static typed language with resemblance to ruby. Which allows for some functional style arguably better than java.Usually 'porting' a language to android is problematic because you need to port the standard library too. Mirah avoids this by avoiding to have a standard lib. In the referenced material there is a nice overview from REAL WORLD experience running mirah on android and how it turned out. (try 2)

share|improve this answer
Please don't repost the same answer, all you had to do to ask for your answer to be undeleted after you edited it was to flag it for moderation attention. –  Yannis Sep 13 '12 at 8:14

There has been a lot of movement on Clojure on Android (
There are performance issues related to the Dalvik VM and the Clojure Compiler; these issues are slowly being resolved.

A presentation about the current (July 2015) status:

share|improve this answer

It's not quite there yet but Miguel de Icaza, a guy who knows a thing or two about the Davlik VM says "F# for droid is on their list of things to do." So I'd say an officialish package is coming.

share|improve this answer

protected by gnat Jul 8 at 22:19

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.