Scala with Android – does anyone have any experience?


Hey? Anyone have any experience with Scala in Android?

I like the syntax a lot, but in fact, it's still the same inside, like Java – so it will probably suit Android


I have experience. The main problem is that android has its own archive format (instead of jar – dex). The format has a limitation of 65,535 methods / per file and scala rests against this limitation. This can be fought with the help of tools such as proguard, which cut out all unused code, and makes a number of optimizations, but it does not work at all quickly and each already not fast cycle "build the application / uploaded to the phone emulator / tested" even more drags on.

Earlier (up to version 2.2, when it seemed like they did JIT in android), the code written in scala was slower than plain java, now this difference is not noticeable. There is a noticeable difference in memory consumption (but difficult places can be written in an imperative style – scala allows, or write in java – as mentioned here, you can mix any jvm languages ​​that are compiled into class files in one project, for example Java, Scala , Clojure, Kotlin and others less popular).

Otherwise, the development is quite pleasant (for example, the plugin that @ murmurmur mentioned allows you to use typed resources, and not to cast each resource that you select by id).

Scroll to Top