Live data from Hacker News

Develop for Android with Scala

code.google.com

11–20 of 21 posts

Re: Develop for Android with Scala

#11
post #4
post #3

Cool! Do you know if this ads much/anything to the apk runtime size? The documentation seems a little bit scarce at the moment. I need to get around to doing up Hecl for Android 'nicely'.

IT includes a proguard.jar file which I assume is used to remove unnecessary classes from your final application. I managed to get Scala working with Android a while ago by following online guides (a lot more hassle than this looks to be!) and I used proguard for this purpose.

It took me forever to get it working for another app, and after I got it working, I decided to start this project, which makes things a lot easier since it just works.

Re: Develop for Android with Scala

#12
post #9

How is the performance compared to straight Java? I know the Clojure on Android project is at the moment, slower due to the functional nature of the language. Apparently the Dalvik garbage collector has to work overtime cleaning up because of the emphasis on creating new objects rather than mutating existing ones.

I have one app in the market that uses it and it runs great.

Re: Develop for Android with Scala

#13
post #9

How is the performance compared to straight Java? I know the Clojure on Android project is at the moment, slower due to the functional nature of the language. Apparently the Dalvik garbage collector has to work overtime cleaning up because of the emphasis on creating new objects rather than mutating existing ones.

> I know the Clojure on Android project is at the moment, slower due to the functional nature of the language.

There are two things that can hurt performance for functional languages on top of the Java VMs ... the lack of TCO and the mapping of a type-system that's too different to be mapped efficiently.

In Clojure though what hurts is its dynamic nature, but you can go a long way by using type-annotations when you discover clear bottlenecks.

Re: Develop for Android with Scala

#15
Nice. I looked into using Scala for an Android app a few months ago, and the number of moving parts involved to get "Hello World" working scared me off. Automating that makes it less scary, so I am glad to see this.

I wish I could write my Android apps in Haskell instead, though. Scala just isn't quite as nice.

Re: Develop for Android with Scala

#17
post #9

How is the performance compared to straight Java? I know the Clojure on Android project is at the moment, slower due to the functional nature of the language. Apparently the Dalvik garbage collector has to work overtime cleaning up because of the emphasis on creating new objects rather than mutating existing ones.

I have one app in the market that uses it and it runs great.

Cool! Which one, out of curiosity?

Re: Develop for Android with Scala

#19
post #9

How is the performance compared to straight Java? I know the Clojure on Android project is at the moment, slower due to the functional nature of the language. Apparently the Dalvik garbage collector has to work overtime cleaning up because of the emphasis on creating new objects rather than mutating existing ones.

You can write Java-like code in Scala that compiles down to nearly identical bytecode to the Java version. If you're not using any primitives it will be 100% as fast.

If you write idiomatic Scala code, or use many primitives in Java code, the performance of Scala becomes relatively worse. Every first-class function you use turns into the equivalent of a new class and object at runtime, and the immutable data structures are slower than their Java equivalents.

I'm not sure how the performance delta differs between the JVM and Android's Dalvik VM. It may be that Dalvik's lack of JIT or less efficient garbage collector makes the Scala performance penalty bigger on Android. I would be interested in seeing some benchmarks.

Re: Develop for Android with Scala

#20
Any Android OpenGL bindings for Scala? I would like to try some 3D stuff with it. The first time I tried 3D stuff on Android, I didn't like the fact that I had to write ~70 lines of Java code just to get a blank black screen
Post reply on HN