

Using Scala in Bump for Android - jmintz
http://devblog.bu.mp/how-we-use-scala-in-bump-for-android

======
fizx
> 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]

~~~
JamieEi
I found this odd as well. I have always heard that it runs faster. For
example: [https://days2011.scala-
lang.org/sites/days2011/files/ws3-1-H...](https://days2011.scala-
lang.org/sites/days2011/files/ws3-1-Hundt.pdf)

~~~
saurik
That paper explains that the Scala engineer performed numerous algorithmic
improvements, whereas the Java one "refused" to (he reported somewhere else,
on a mailing list? that he wasn't told it was for a paper). The paper also
explains that using Scala idiomatic for-comprehensions produced very slow
results.

------
ysph
"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
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
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_...](http://kotka.de/blog/2010/02/gen-
class_how_it_works_and_how_to_use_it.html)

~~~
rickmode
Ya. I was implementing an abstract class so gen-class was the only way.

------
DanielRibeiro
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>

