Saying Kotlin Image Processing (KSP) Alpha

Posted by Ting-Yuan Huang‎, Software program Engineer and David Winer, Product Supervisor

Android image

Right now we’re excited to announce the alpha of Kotlin Image Processing (KSP), an all-new software for constructing light-weight compiler plugins in Kotlin. KSP provides related performance to KAPT, nevertheless it’s as much as 2x sooner, provides direct entry to Kotlin compiler options, and is being developed with multiplatform compatibility in thoughts.

KSP is appropriate with the Kotlin 1.4.30 launch and onwards. You may take a look at the open supply code and documentation within the KSP GitHub repository.

Why KSP?

The #1 request we hear from Kotlin builders is to make construct speeds sooner. Many builders iterate on and deploy apps dozens of occasions a day, so having to take a seat round ready for a gradual construct might be very time consuming. One of many greatest challenges with compiling Kotlin code is that Kotlin doesn’t have a local annotation processing system. Annotation processors like Room are ubiquitous on Android and depend on Java annotation processing compatibility by way of the Kotlin Annotation Processing Software (KAPT). KAPT might be gradual to run, although, because it requires producing intermediate Java stubs that may then be ingested by the Java annotation processing system.

When designing KSP, we thought of what annotation processing would seem like for Kotlin if we constructed it from the bottom up. KSP provides a robust and but easy API for parsing Kotlin code instantly, dramatically decreasing the construct pace tax imposed by KAPT’s stub era. Certainly, preliminary benchmarks with the Room library present that KSP is roughly 2x sooner than KAPT.

Getting began

To see what KSP appears like in motion, obtain the KSP playground project from GitHub. In it you’ll discover:

  • Library: A toy test-processor library that implements the builder sample as a KSP processor
  • Consuming venture: A workload listing that reveals how one can use the builder processor in a real-world Kotlin venture

All the logic for implementing the builder is in test-processor — for the patron (workload), the one distinction between utilizing KAPT and KSP is a two-line construct file change:

That is the purpose of KSP: most Android app builders don’t want to fret about its internals; apart from this one line change, a library that helps KSP appears similar to a traditional annotation processor, solely it’s as much as 2x sooner. That stated, utilizing KAPT and KSP in the identical module will possible decelerate your construct initially, so throughout this alpha interval, it’s best to make use of KSP and KAPT in separate modules.

As extra annotation processors undertake KSP, we count on most of your modules to have the ability to use KSP as a close to drop-in alternative for KAPT. For now, you may take a look at which annotation processors supply KSP assist in this table. If a library that helps or is implementing assist for KSP is lacking from the desk, please submit a pull request along with your suggestion!

In case you are an creator of a library that at the moment makes use of annotation processing, you will discover extra data on how one can make your library appropriate with KSP within the quickstart and README guides.

For library authors, now that KSP is in alpha, it’s a good time to begin wanting intently at it and giving us suggestions on the API within the KSP issue tracker. As well as, we usually submit launch updates within the #ksp channel on Kotlin Slack. For the reason that developer preview final June, we’ve closed over 100 bugs and points, dozens of which have been reported by the superb group of Kotlin library builders.

Java is a registered trademark of Oracle and/or its associates.

Recent Articles

Google Cloud targets Indian public sector for development

Google Cloud has introduced that it has achieved full Cloud Service Supplier (CSP) empanelment by efficiently finishing the STQC (Standardisation Testing and High quality...

Anker beats Apple to market, new iPhone 12 MagSafe-compatible battery pack now out there – 9to5Mac

The favored accent maker Anker has formally launched a brand new MagSafe-compatible wi-fi energy financial institution for iPhone 12 customers. This comes as rumors...

10 greatest Star Wars apps for Android

Star Wars is among the largest tales people ever informed. It spans a number of many years, a number of motion pictures, a number...

Related Stories

Stay on op - Ge the daily news in your inbox