Settings

Theme

Using Scala in Bump for Android

devblog.bu.mp

46 points by jmintz 15 years ago · 12 comments

Reader

fizx 15 years ago

> Scala runs a little slower than Java (I've heard about 6x in benchmarks, but I'd bet it's worse in Dalvik),

[citation required]

ysph 15 years ago

"Scala works very well with existing Java frameworks. Android is, of course, one big Java framework and we were going to have to interface with it a lot. A number of people asked, given the above, why not use Clojure--this is why."

Since when does Clojure not work well with existing Java frameworks? I wouldn't advocate Clojure or Scala one way or the other since I have little idea of what they're doing, but the above doesn't strike me as sound reasoning.

  • rickmode 15 years ago

    Using Java classes and interfaces from Clojure is straightforward. Instantiating objects is easy. Implementing Java interfaces is easy. Both are fluid and feel idiomatic.

    On the other hand, extending an existing Java class is quite awkward, requiring the use of gen-class, and does not (IMHO) feel idiomatic. I found the gen-class facility poorly documented. It also has a potentially small performance penalty due to an extra dereference (though in my testing I could not measure a meaningful difference between a gen-class object and a native Java implementation).

    So Clojure is nice for using Java stuff from Clojure, however it becomes awkward for using Clojure stuff from Java.

    • nomurrcy 15 years ago

      I've never found it to be that awkward to extend existing classes from java. Part of the problem in clojure are there are so many different ways to do it, all with different shortcomings.

      For simple adding of a protocol to a class you can always just use (extend-class)

      Proxies are simple and work well in other cases.

      the gen-class documentation is a bit confusing, it helped me to look @ some examples. I used a different site that I can't find now, but this one seems helpful.

      http://kotka.de/blog/2010/02/gen-class_how_it_works_and_how_...

  • willbmoss 15 years ago

    I wrote the post and to clarify, I didn't mean to suggest that interfacing with Android was impossible with Clojure, simply that is was easier with Scala. As rickmode points out, there are some things that make Clojure more difficult.

  • kikibobo69 15 years ago

    Agreed, not sound reasoning, but here's a nice summary of the challenges of Clojure on Android: http://stackoverflow.com/questions/4651757/clojure-on-androi...

  • technomancy 15 years ago

    Yes, there are several reasons not to use Clojure on Dalvik, but this is absurd.

DanielRibeiro 15 years ago

I've fixxed a getting started project using the latest Android SDK and Scala 2.9: https://github.com/danielribeiro/HelloScalaOnAndroid

Edit: The pull request was accepted at: https://github.com/gw111zz/HelloScalaOnAndroid

Keyboard Shortcuts

j
Next item
k
Previous item
o / Enter
Open selected item
?
Show this help
Esc
Close modal / clear selection