Introduction
JVM languages
Which languages you can write a Kest application in, and how each one is wired.
Kest wires a Kotlin or Java application at build time: a KSP processor reads your annotated classes while the compiler runs and generates the connecting code. KSP only understands Kotlin and Java, so for Scala, Groovy and Clojure Kest has a second path that does the same job at start-up by reading the annotations through reflection (the reflect package) or, for Clojure, a small data-and-functions API.
| Language | Status | How it is wired | Build tool |
|---|---|---|---|
| Kotlin | supported, the primary language | build time (KSP) | Gradle |
| Java | supported and tested (examples/java-api, with a real PostgreSQL) | build time (KSP, hosted by the Kotlin Gradle plugin) | Gradle |
| Scala | supported, tested over real HTTP (examples/scala-api) | start-up, by reflect | Gradle (scala plugin) |
| Groovy | supported, tested over real HTTP (examples/groovy-api) | start-up, by reflect | Gradle (groovy plugin) |
| Clojure | supported, tested over real HTTP (packages/clojure) | start-up, from kest.core data | Gradle |
| Maven build | not supported yet (planned, next) |
How to set each one up, with working code: Scala, Groovy and Clojure.
What the start-up path gives up
The build-time path checks your wiring while compiling: a missing provider or a circular dependency is a build error. The start-up path finds the same problems, but when the application starts (still before it serves a request, and with the same messages). It also has a little more work to do at start-up, which for a typical application is a few milliseconds.
Everything else behaves the same: the descriptors it builds are the ones the processor would have generated, so guards, interceptors, pipes, filters, validation, versioning and forwardRef all work, and a module written in one style can import a module written in the other.
Not covered on the start-up path today: the ORM and other processor-generated parts (entities, repositories, GraphQL schemas, microservice and WebSocket handlers). Use Kotlin or Java for those, or keep them in a Kotlin subproject that the Scala or Groovy application imports.
Choosing between Kotlin and Java
| Kotlin | Java | |
|---|---|---|
| nullable parameters are optional | String? | @Nullable |
| parameter names in routes | automatic | write @Param("id") / @Query("name") (Java does not keep names) |
| coroutines | yes | handlers are blocking (virtual threads make that cheap) |
data classes and copy for entities | yes | classes or records (relations are not supported on records) |
| extra build setup | none | the Kotlin Gradle plugin as a host for KSP |
Both languages can live in the same project, and a library written in one can be used from the other.