What does it mean that Kotlin based apps will get a performance boost on Android P

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP


What does it mean that Kotlin based apps will get a performance boost on Android P



Over the last few of months in a bunch of places I've seen the information that Android P will give the performance boost to Kotlin based apps (e.g. here and here).



On the official Android blog, Dave Burke in "Previewing Android P" post described it in a few words:



Kotlin is a first-class language on Android, and if you haven't tried it yet, you should! We've made an enduring commitment to Kotlin in Android and continue to expand support including optimizing the performance of Kotlin code. In P you'll see the first results of this work -- we've improved several compiler optimizations, especially those that target loops, to extract better performance. We're also continuing to work in partnership with JetBrains to optimize Kotlin's generated code. You can get all of the latest Kotlin performance improvements just by keeping Android Studio's Kotlin plugin up-to-date.



Does it mean that Kotlin can be optimised more than Java? Isn't true that kotlinc together with javac produces the Java bytecode (as Jake Wharton explains here). Or is it something what d8 dexer will take care off? But then won't it be applied to all Android versions? Has Dave meant that new tools for devs to optimise Kotlin code will be releases together with Android P?


kotlinc


javac


d8



Is it possible to differentiate java bytecode coming from Java and Kotlin In the first place? Or does it mean that ART will run java bytecode from Kotlin differently?


java bytecode


Java


Kotlin


java bytecode


Kotlin




1 Answer
1



The r8 tool is gaining the ability to detect specific bytecode patterns produced by the Kotlin compiler and to translate them into more efficient Dalvik bytecode. This doesn't mean that Kotlin can be optimized more than Java, only that Kotlin produces bytecode with a somewhat different structure.


r8



The new r8 tool can also be used to compile apps targeting earlier Android versions, with the same performance gains.



This podcast gives some additional background on r8 and its optimizations: http://androidbackstage.blogspot.com/2018/01/episode-86-its-gr8.html






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Makefile test if variable is not empty

Will Oldham

'Series' object is not callable Error / Statsmodels illegal variable name