8 ms·
Kotlin compiles to jvm 1.6 bytecode, so even though it is a different language it runs the same as Java 6 on the devices. Supporting Java 8 requires updating t
by krschultz 11y ago
Kotlin compiles to jvm 1.6 bytecode, so even though it is a different language it runs the same as Java 6 on the devices.
Supporting Java 8 requires updating the vm & OS, which is difficult to do in the Android ecosystem. It may happen in the future but backwards compatability will be tough since the phone manufacturers lag so badly on platform upgrades. I'm not even getting into the Oracle v Google spat that may slow down adoption of a newer version of Java.
For that reason Kotlin is a lot more viable today than Java 8. Maybe someday Java 8 will make it to Android, but that day is definitely not today. Even after it is released in the newest devices, it probably won't be widespread for 18+ months.
edit: no one should downvote the parent question it is a legit technical ask without an obvious answer.
- cdbattags 11y agoIt might be a stupid ask, but: What would it take for Android to start support for a different dev language (being able to write an app in js or Swift for example)? Also, is it never the case that when a new language is released (Java 8 for example) there is usually a strong emphasis on backwards compatibility (compiling into all or a few previous versions' bytecodes)?
- acveilleux 11y agoYou can get Java 6 bytecode from a Java 8 compiler but it will fail to compile if you used Java 8 features: $ jdk-1.8-64/bin/javac -target 1.6 -source 1.6 LambdaTest.java warning: [options] bootstrap class path not set in conjunction with -source 1.6 LambdaTest.java:16: error: lambda expressions are not supported in -source 1.6 Runnable r2 = () -> System.out.println("Hello world two!"); ^ (use -source 8 or higher to enable lambda expressions) 1 error 1 warning Trying to heed the error: $ jdk-1.8-64/bin/javac -target 1.6 -source 8 LambdaTest.java javac: source release 8 requires target release 1.8
- bitmapbrother 11y agoOut of curiosity, why would the Android ART VM care about what language version, or language for that matter, was used to create the DEX byte code? As long as the DEX byte code generator is able to convert the original byte code to DEX byte code isn't that all that really matters?
- izacus 11y agoYes, but the issue with Java 8 is that it requires new bytecode commands (mostly related to handling lambdas and method references) and is thus not compatible with older JVMs. There is a project that patches Java 8 bytecode and replaces all lambda invocations and method references with anonymous class instantiations. It's called RetroLambda and lets Android devs use Java 8 lambdas in their code. It does open a whole new pit of issues though.