4 ms·
I would like to share my experience with Scala and Android. Maybe someone can tell me what I am doing wrong. Speed and start up time does not appear to be a pr
by Dn_Ab 15y ago
I would like to share my experience with Scala and Android. Maybe someone can tell me what I am doing wrong.
Speed and start up time does not appear to be a problem, even if you are using a good part of the library. The problem with scala is it takes so darn long to build your simple app. Size of generated output is not a big deal, though it will be larger than Java for simpler stuff. But unless your app is trivial the media elements will make a much larger contribution to your final size than the code. Also the growth is non linear. Here is what I mean.
If you hello world and proguard your app will be the same size as a java app. But once you bring in some scala stuff - collections or language features which need the library it grows by an order of magnitude. So a 20k Java app vs 100k Scala for the same app. After that initial bump the additional baggage is gradual so that eventually the java app of similar complexity will generate similar sized output. Speed is not meaningfully impacted in my experience. If you are making a game it would be worth considering preallocating arrays and doing basic memory management to avoid stalls.
You will have to avoid some idiomatic scala because functional programming is too easy going in terms of allocation. So manually iterating java hashtables and arrays instead folding over maps and lists. I will note that for my simple app I fold over lists with little impact for now. Scala has the basic advantage of being a java with less boilerplate. The little things add up. But if you are not using it as a functional language is it worth it? I think so. Instead of using it as just a functional language you can use it as something else. more? By leveraging caseclasses, Extractors and pattern matching you gain in expressivity while retaining declarative elegance. your mileage may vary.
So the problems are: You can't easily debug. But Mostly, building takes Forever. It takes 4-5 minutes to build the simple hello world activity. I humbly suggest the scala team look at their android support.
Getting F# on WP7 was a piece of cake in comparison. Building is normal, debugging is there and getting it to work was a matter of referencing a targeted dll.