0Pricing
Kotlin Academy · Lesson

KSP vs KAPT: Why KSP Is Faster

Compare KSP and KAPT processing models and understand the performance benefits.

The Problem with Annotation Processing

Annotation processors generate code at build time. For years, Kotlin projects used KAPT — Kotlin Annotation Processing Tool — which works by converting Kotlin source to Java stubs before passing them to Java annotation processors. This conversion is costly.

How KAPT Works

KAPT runs the Kotlin compiler to produce Java stub files, then runs Java annotation processors (APT) on those stubs, then compiles everything together. Every build step adds latency:

  • Kotlin → Java stubs compilation
  • Java APT processing on stubs
  • Final Kotlin + generated-source compilation

All lessons in this course

  1. KSP vs KAPT: Why KSP Is Faster
  2. Writing Your First SymbolProcessor
  3. Generating Kotlin Source Files with KotlinPoet
  4. Integrating KSP Processors into a Gradle Build
← Back to Kotlin Academy