Alex Rivera | Logout

Is using Scala on Android worth it? Is there a lot of overhead? Problems?

Asked 2010-10-11T13:16:30.063
28

I was thinking of building an app on Android with Scala instead of the regular Java (or the equivalent I guess). Is it worth it?

Any problems and unnecessary headaches?

Edit
Report

1 Answer

15

There is a talk by guys from bu.mp on Scala Days 2011.

Disclaimer: While they talk a lot about issues they've faced, the overall experience was definitely positive. Moreover, this were the problems of one particular team and they are minor ones.

Summary:

  • Memory usage. Closures eat memory. Scala has closures all over the place. While it is not a relative big problem (memory overheads) on your table PC, it should be considered when you develop for mobile phone. You may ask: how they solved it? They had a hunt for a tight loops and then optimized them (rewritten in closureless scala/java). (26th minute) I think Java 8 with native closures support will ease this problem Next scala release will target java 8 platform with a new backend and aim for much better performance. Discussion on roadmap is here.
  • Slower compiler (as Michal Galpin said they have 15 seconds for Java code compilation, about a minute for Scala and about an order a magnitude more for Proguard, but note that it depends on your code base and machines, but I suspect that ratio will be the same). It especially annoying when you making UI, like moving pixels, buttons and so on, and want to quickly see the result. (7th minute)
  • There were some issues with inner classes which are quite common for Android (look at 23:00 for details).
  • There were rare bugs in scalac (scala compiler) in scala-java-collections interop. The problems were solved by writing this things explicitly (I suspect that is not a lot of boilerplate at all).

While he talks about IDEs too, I don't think that it is a problem (look this post, about Scala environm

answered 2012-04-27T21:35:13.527

Your Answer