top | item 7844665

(no title)

nilium | 11 years ago

> Scala has slightly more overhead though from making lots of small objects

This is definitely true, though it's possible to write code that avoids it. It just ends up being slightly uglier Scala. The renderer in Ascension, for example, is all fairly bare-bones Java-like Scala because I have to be careful about how certain code is generated (i.e., prefer a while loop or tail recursion to a for comprehension or .foreach). So, it's possible to get performant code, it just ends up being more like Java usually.

In the UI code, you can get away with a little more depending on where it is. If it's inside an adapter, it pays to avoid the heavier tools Scala gives you. If it's responding to a button press, you probably don't need to worry as much. The GC will run a little more often, but the GC in Android has improved a fair bit over time.

I'll second the Java collections recommendation though — as much as I like the immutable collections provided by Scala (and I do use a few of them), they're much free-er with their allocations than Java and Android's. I haven't tried anything with actors on Android yet, though, so I can't comment on that. I just use AsyncTask as carefully as possible right now, but I really need to get familiar with an alternative to that. I'd like to try actors, plus I'd also like to get into using something like RxJava/Scala, but I haven't had anything come up where I could afford to experiment with it. Also need to see how Akka fares on Android, but same problem as RxJ/S.

discuss

order

No comments yet.