News for hackers. Stuff that matters.

gregghz

Re:Why I Don’t Regret Moving Our Android App to Scala on Thursday July 13, 2017 @03:14PM (#14764267)
I honestly don't know.
Re:Why I Don’t Regret Moving Our Android App to Scala on Wednesday July 12, 2017 @10:58PM (#14758409)
you don't. Scala produces them automatically for case classes. Kotlin will treat x.count as x.getCount() if getCount exists and count doesn't. They are mostly a side effect of the tools and not strictly required.

Especially in Kotlin and Scala where data tends to be immutable by default there isn't much to gain by using getters.

If your "getter" is doing more than getting the value then maybe you should not call it a getter (imo).

Re:Why I Don’t Regret Moving Our Android App to Scala on Wednesday July 12, 2017 @09:34PM (#14758150)
Well we also used Swift way before a "stable" release came out. So maybe we're masochists.
Re:Why I Don’t Regret Moving Our Android App to Scala on Wednesday July 12, 2017 @09:29PM (#14758132)
FWIW, google adopting a second JVM languages means that Android tools will trend toward operating on bytecode and not source where applicable. They released some annotation processors for Room and their lifecycle stuff that operate entirely on bytecode so work well enough with Scala.
Re:Why I Don’t Regret Moving Our Android App to Scala on Wednesday July 12, 2017 @09:20PM (#14758111)
> compilation times, to method counts, to binary sizes, to performance

besides compile times (mitigated almost entirely by incremental compilation) none of these things hold up. Method counts are irrelevant with proguard and multi-dex (FWIW, most of our count comes from google support libraries anyway). Our binary is around ~5mb. I haven't ran benchmarks but I promise you that http requests, writing to disk, and WebView performance aren't slower because of Scala.

Re:Why I Don’t Regret Moving Our Android App to Scala on Wednesday July 12, 2017 @09:17PM (#14758095)
> sbt-android doesn't allow you to use Android Studio, which is also a huge handicap.

Some of our team uses Intellij, some use Android Studio to do Android dev. Both work fine with sbt-android.

> You can use the same libraries, the same build system, the same IDE.

This is true of Scala as well. Granted the gradle scala plugin is not great (though it does seem much better than when I last looked at it). sbt-android-gradle lets you use gradle and sbt side by side for android apps. For a while my team used this.

> The sbt-android plugin mentioned may work, but will never have the feature set of Gradle integration.

I'm curious if you know of any of these features sbt-android is currently misisng. I believe some of the new Android O font stuff might not work yet. Instant Run might be the next thing to be mentioned but it's replaced really well by sbt-android-protify.

> Scala 2.12 requires Java 8, and support for Java 8 bytecode has only been introduced in O

This is (imo) the worst part about all of this. Even Android O isn't the full java 8 bytecode so scala 2.12 still doesn't work.

> all of this is why Android developers love Kotlin

Yeah, I think Kotlin is a godsend for Android. One thing I don't think I mentioned in my original post was that Scala benefits from Google's kotlin support as well. It means many tools google produces (new arch components come to mind) operate on bytecode instead of source. So they (more or less) automatically work for scala too.

Certainly kotlin was thought of from the ground up as an Android language and it shows.

You also mention method counts a few times. I admit this is somewhat of a problem but it's also worth pointing out that sbt-android runs proguard automatically for you during release builds. We haven't come close to 65k (with or without proguard) and 70% of our method count comes from android support libraries published by google not the standard library methods provided by scala. We also target api 21 so multi-dex is not really the headache for us that it used to be.