Google: This Kotlin tool will help your Android apps build faster

Google releases Kotlin Symbol Processing to speed up Android app development.

Google has announced an alpha version of its Kotlin Symbol Processing (KSP) tool for building compiler plugins in the modern application development language, Kotlin.

KSP is compatible with Kotlin 1.4.30, which Czech software developer firm JetBrains released last week as a precursor to Kotlin 1.5.0

Kotlin has been endorsed by Google as a language for developing Android apps. Kotlin is now used by over 60% of professional Android developers and is an alternative to building apps with Java: Google engineers wrote about 30% of the Google Home app in Kotlin after translating it from legacy Java code.

SEE: Hiring Kit: Python developer (TechRepublic Premium)

According to Google, the top request from Kotlin developers is to speed up build times during compilation.

"Many developers iterate on and deploy apps dozens of times a day, so having to sit around waiting for a slow build can be very time consuming," said Google's Ting-Yuan Huang and David Winer

One of the biggest challenges with compiling Kotlin code is that Kotlin doesn't have a native annotation processing system, while annotation processors like Room are commonly used on Android and rely on Java annotation processing compatibility through the Kotlin Annotation Processing Tool (KAPT). 

KAPT, however, can be held back by intermediate Java stubs that need to be ingested by the Java annotation processing system, something that KSP tackles.

"KSP offers a powerful and yet simple API for parsing Kotlin code directly, dramatically reducing the build speed tax imposed by KAPT's stub generation," note Huang and Winer.  

Google claims initial benchmarks with the Room library show that KSP is approximately twice as fast as KAPT.

"This is the goal of KSP: most Android app developers don't need to worry about its internals; other than this one line change, a library that supports KSP looks just like a normal annotation processor, only it's up to 2x faster."

SEE: Developer: Rust programming language is being used for bigger projects

Google expects developers of Android libraries and software modules to adopt its KSP annotation processors and replace KAPT. 

For now, KSP partially supports Room, and experimentally supports Moshi. Also in sights are Auto Factory, Dagger, Hilt, and Gilde, but none of the latter are supported yet. 

"For library authors, now that KSP is in alpha, it's a great time to start looking closely at it and giving us feedback on the API in the KSP issue tracker. In addition, we regularly post release updates in the #ksp channel on Kotlin Slack. Since the developer preview last June, we've closed over 100 bugs and issues, dozens of which have been reported by the amazing community of Kotlin library developers," Huang and Winer note.