10

I'm very new to scala and find many of its ideas very attractive. I've just discovered the scala for android project and I'm wondering if it could be expected to run well or perhaps even better than java?

Could it even be expected do some things better than java even if the processors are mostly single core in-order execution types at the moment?

If anyone has any example or experiences to share then please do!

barrymac
  • 2,750
  • 1
  • 20
  • 32
  • Oh! just noticed [this related question](http://stackoverflow.com/questions/476111/scala-programming-for-android) ! – barrymac Jun 02 '11 at 13:54
  • The related question is 2 years old, maybe add a (June 2011) to your title, so we can keep track of how scala/android changes over time? – Jamie Jun 03 '11 at 01:37

3 Answers3

8

The only "lag" would be the size of the apk, but if you use something like ProGuard it would represent only around 15k/25k more, nothing significant at all. As of performance, for what i've seen is the same. I mean, it is not worse (as happens with Clojure, being dynamically typed), but i think it's the same as Java.

ferostar
  • 7,074
  • 7
  • 38
  • 61
  • 4
    While Clojure being more functional or not is debatable, that has nothing whatsoever to do with relative performance. What makes a difference is that Clojure is dynamically typed, while Scala is statically typed. – Daniel C. Sobral Jun 02 '11 at 14:29
  • 11
    A more functional style usually leads to more garbage creation/collection, and impacts performance that way. Scala is nice because mutable variables are natural to use where performance is important, and a functional style can be used elsewhere. – Kipton Barros Jun 02 '11 at 16:43
  • 1
    But Scala uses a bit more memory than Java (when used idoimatically). – ziggystar Jun 03 '11 at 07:07
2

Yes, it does. But to keep the package size down, use Proguard.

If you use SBT, there is already some plugin which automates the whole process.

soc
  • 27,983
  • 20
  • 111
  • 215
0

As with most performance-related questions, the correct answer is 'It depends'. I'm no Scala expert (yet), but from what I've seen so far, it'll be future-proof - as in, build with Scala to get better / easier multicore support - as that's the trend that's rapidly popularizing, with dual- and quadcore processors quickly becoming commonplace in high-end smartphones. For single-core and 'simple' applications that don't really do much things that can be parallized, I'm guessing performance would be equal or worse. However, performance isn't everything, especially not for prototypes or one-off applications - ease of coding and development speed are more important, in which Scala, if you're familiar with it, can help (due to less code and smarter constructs).

cthulhu
  • 3,142
  • 2
  • 23
  • 32