4 ms·
Yes, Scala is currently the best alternative to Java for Android development, but I am hoping that Clojure can close the gap significantly. The main drawback t
by daniel_solano 14y ago
Yes, Scala is currently the best alternative to Java for Android development, but I am hoping that Clojure can close the gap significantly.
The main drawback to Clojure is still the start-up time, but that's getting better. For example, the metadata elision introduced in Clojure 1.4.0 speeds things up a bit and makes a significant cut in Clojure’s heap use.
However, one thing that Clojure gives you that Scala cannot, is the ability to do REPL-driven Android development, i.e. sending code directly from your editor to a running application and seeing nearly instantaneous results.
One thing I hope will help Clojure significantly is that it has a Google Summer of Code student who is going to be working on improving the tooling support for Android and Clojure. This should make it much easier for Clojure developers to start creating Android applications.
- lucian1900 14y agoBeing able to use Clojure would be great, but as you said not a viable option yet. GC pressure is the biggest problem, and it's one that sadly won't get solved too soon. I've also looked at kawa (scheme), I might try that.
- daniel_solano 14y agoIf I am not mistaken, any JVM language that has immutable data structures and closures is probably going to generate a fair bit of garbage. I believe this also applies to using Scala functionally. My understanding is that there is greater interest in making Clojure more suitable as a library and with a leaner runtime requirement. If you have a situation were you don't need a dynamic environment, having the option to compile functions to static methods instead of classes should result in a big performance increase. I have only briefly looked at Kawa Scheme, but I have not had the time to do much with it beyond a "Hello, World!" sort of project. Mirah is another interesting option. It uses a Ruby-inspired syntax but requires no runtime library.
- lucian1900 14y agoYes, immutable data will generate garbage. The problem with Clojure is that it generates a ton of garbage during start up, which isn't the case with Scala. I certainly welcome any improvements in Clojure. I've looked at Mirah, but it's quite immature and has serious problems with Java generics because of Java's type erasure.
- cageface 14y agoMy understanding is that Clojure also relies heavily on some of the advanced Hotspot optimizations that aren't available in Dalvik so it's often much slower on Android than it is on the standard JVM.
- daniel_solano 14y agoReally? I haven't heard of that. In my experience, most of the alternative compiled JVM languages, i.e. Scala, Clojure, Mirah, and JRuby, seem to run fairly comparable to each other once they have started. The biggest differentiator between them with respect to performance seems to be in the way of start time and heap overhead ranging from none (Mirah) to substantial (JRuby).
- cageface 14y agoNaively written Clojure is going to run a lot slower than Scala because it's doing a lot more dynamic dispatch. With the right type annotations you can probably get them fairly close.
- lucian1900 14y agoAfaik it's about Hotspot having a much, much better GC.