Update 3. KOTLIN IS NOW OFFICIALLY SUPPORTED FOR ANDROID DEVELOPMENT. BY GOOGLE. YAAAAAAAAS!
Update 2: It looks like JetBrains is really committed to supporting Kotlin for Android in the long run. I'm a happy kotlin user :).
Update: Hadi Hariri, from JetBrains, mentioned they're going to release some info on this topic. I will update this post once they do.
=== DEPRECATED STUFF NEXT ===
Google just released a preview for the upcoming Android N with some interesting features, the most notable being partial Java 8 language support. This is possible due to the new Jack toolchain Google is working on.
The current toolchain using javac or kotlinc:
javac (.java
--> .class
) --> dx (.class
--> .dex
)
kotlinc (.kt
--> .class
) --> dx (.class
--> .dex
)
New Jack toolchain:
Jack (.java
--> .jack
--> .dex
)
I am assuming Google will push forward towards making Jack the default toolchain for Android development. Update: Jack is now deprecated. Yas.
My question is how will this new toolchain affect me, in the future, as a kotlin user for Android development? Will I get "stuck in the past"?
disclaimer: I work on Jack
This won't affect you. Kotlin's compiler produces Java 6 bytecode, which Jack/Jill can import just fine.
@Pavel Dudka
Jack - is a compiler. Similar to javac, but it does a slightly different thing:
As you can see, Jack compiles Java source code straight into Dex file! We don't have intermediate *.class files anymore, so dx tool is not needed!
But wait! What if I include a third-party library in my project (which comes as a collection of .class files)?
And that's when Jill comes into play:
Jill can process class files and transform them into special Jayce format which can be used as an input for Jack compiler.
So now let's step aside for a second and think... What is going to happen to all those cool plugins we got so addicted to? They all need .class files and Jack compiler doesn't have those anymore...
Luckily, Jack provides some of those important for us features out of the box:
Jack supports Java programming language 1.7 and integrates additional features described below.
Predexing
When generating a JACK library file, the .dex of the library is generated and stored inside the .jack library file as a pre-dex. When compiling, JACK reuses the pre-dex from each library. All libraries are pre-dexed.
Incremental compilation
Incremental compilation means that only components that were touched since the last compilation, and their dependencies, are recompiled. Incremental compilation can be significantly faster than a full compilation when changes are limited to only a limited set of components.
Repackaging
JACK uses jarjar configuration files to do the repackaging.
Multidex support
Since dex files are limited to 65K methods, apps with over 65K methods must be split into multiple dex files. (See ‘Building Apps with Over 65K Methods’ for more information about multidex.)
Google is not going to push Jack as the default tool, but Jack and Jill
.
Compiling .class files to dex with Jill is here to stay. Otherwise, you can say goodbye to jar/aar libraries.
Whether Jack or Jill will be slower is still up for debate. The Android team hopes that jack will be faster than the current build process, but that's not the case right now
Furthermore, Jack and Dex are available in the open, nothing prevents the kotlin team from writing a tool emiting .jack or .dex files from kotlin sourcecode.
UPDATE (03/16/2017)
Luckily, Jack is dead and so it won't affect Kotlin developers.
If Jack is the future then you will get stuck in the past with Kotlin. Currently Jack doesn't support plugins that can compile non-Java source into Dalvik bytecode. And even if it did JetBrains would need to add a new backend to the Kotlin compiler which is not a trivial task. So you will have to use Kotlin with Jill and it's going to be something very similar to the toolchain you use now.
As you can see in the image below even if it's impossible to explicitly turn off Jack you'll still be able to convert the project to a library project to use Jill. And the application project will just reference this library project.
The only way I see how Kotlin can work with Jack, which probably will not be implemented, is adding a Java backend to the Kotlin compiler, i.e. a backend that generates Java code like Xtend. In this case code generated by the Kotlin compiler can be processed by Jack as any other Java code.
But at the moment we don't know exactly what Jack will support when it's released. Maybe something will change dramatically and adding Kotlin support to Jack will become possible.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With