Re:Android now supports Kotlin
by hyperpallium on Thursday May 18, 2017 @12:08AM
(#14364738)
Bit of an aside, but is the Kotlin compiler itself runnable on JVMs supporting Java 6? So you could compile on an Android device.
It's supported all the way down to java 6.
I think you need JDK8 to compile Kotlin, but I'm not 100% sure.
Re:Android now supports Kotlin
by devdoomari on Wednesday May 17, 2017 @09:33PM
(#14364259)
thought recent android's tools update meant I can use java8 on android devices...
guess that requires a recent android device :(
The devices themselves still run a JVM (Dalvik and ART) that's basically compatible only with ~JRE7 bytecode. There are some new features in ART since N, but still the JVM isn't fully Java 8 compatible (afaik invoke-dynamic for lambdas is still not supported).
So the Java 8 tools you're talking about essentially take Java 8 compiled bytecode and patch out the parts that aren't compatible with device JVM (e.g. they replace lambda invocations with anonymous classes like you'd use on Java 6 etc.).
This doesn't work for things like Scala which use these new features in patterns those tools can't patch/recognise.
Kotlin compiler generates code that's runnable on JVMs supporting Java 6, which makes it work on pretty much any Android device, even running older Androids.
Scala standard library is also huge and pretty much immediately hits the 64K method limit of DEX files forcing you to use the very slow proguard compilation step when running it. It also has issues with interoperability with existing Java 6 code.
All in all, Scala is a terrible value proposition in comparison to Kotlin which was built from ground up to modernize programming while still keeping full compatibility with Java 6 code and JVMs stuck on Java 6 language level.