Skip to content

14. Further Reading

This document introduced the Kotlin language and the most commonly used libraries for writing layered applications, network clients and servers, and web services on the Java Virtual Machine. Here are the main topics that build on this.

14.1. Processing XML documents

JSON has largely replaced XML for data exchange, but XML is still in use (configuration files, document formats, existing SOAP services). Kotlin directly uses the XML API of the JDK, within the [javax.xml] package:

  • DOM ([DocumentBuilder], [Document], [Element]): the document is loaded into memory as a tree, which is then traversed and modified;
  • StAX ([XMLStreamReader], [XMLStreamWriter]): the document is read or written on the fly, without being loaded entirely into memory;
  • XPath ([javax.xml.xpath]) to query a document, and XSLT ([javax.xml.transform]) to transform it.

Aside from JDK, Jackson can read and write XML using its [jackson-dataformat-xml] module, just as it does for JSON (Chapter 5), and the kotlinx.serialization library for JetBrains, which generates serialization code at compile time, also supports XML formats developed by the community.

14.2. Web Applications

Chapter 13 covers only web services (applications that produce data). For web applications that generate HTML pages, or for other ways to write web services in Kotlin, the following are available:

  • Spring MVC with a template engine like Thymeleaf: server-side generated pages. Spring supports Kotlin just as it does Java (data classes, coroutines in controllers, Kotlin for route configuration); the author wrote the course “Step-by-Step Introduction to the Spring Web Framework” (September 2026);
  • Ktor, the JetBrains web framework, written in and for Kotlin: HTTP servers and clients built on the coroutines from Chapter 9, configured using Kotlin code rather than annotations;
  • other JVM frameworks that support Kotlin: Quarkus, Micronaut, Javalin, and the Jakarta application servers EE;
  • interfaces written in JavaScript (Vue.js, Angular, React) that consume Kotlin web services; the author wrote the course “Step-by-Step Introduction to the Vue.js Framework” (September 2026). Kotlin itself can be compiled to JavaScript (Kotlin/JS) or to WebAssembly (Kotlin/Wasm), which also allows the client-side to be written in Kotlin.

14.3. Mobile and Desktop Applications

This document does not cover graphical user interfaces: today, management applications are most often built with web interfaces. However, this is an area where Kotlin is widely used:

  • on Android, Kotlin is the language recommended by Google, and the UI is built using Jetpack Compose, a declarative library written entirely in Kotlin; coroutines (Chapter 9) are used to keep the UI responsive during network or database access;
  • Compose Multiplatform, by JetBrains, extends Compose to write desktop (Windows, Linux, macOS), iOS, and web interfaces using the same code;
  • More generally, Kotlin Multiplatform allows business logic code (the [business] and [dao] layers in Chapter 6, for example) to be shared between JVM, Android, iOS (via Kotlin/Native, which generates machine code without a virtual machine), and the web;
  • on JVM, the Java Swing and JavaFX libraries remain usable from Kotlin. The concepts covered in Chapters 7 (event listeners) and 9 (returning to the GUI thread with [Dispatchers.Main]) apply directly here.

14.4. Tests

Chapter 6 introduces JUnit and [kotlin.test]. These are often supplemented by:

  • Kotest, a testing framework written for Kotlin, offering multiple test-writing styles and a rich library of assertions ([list shouldHaveSize 7]);
  • MockK, the library of “mocks” (simulated objects) for the layers on which the layer under test depends, designed for Kotlin (final classes, objects, suspension functions); Mockito remains usable;
  • kotlinx-coroutines-test, which runs tests on coroutine-based code using a virtual clock: a [delay(10_000)] runs instantly;
  • Testcontainers, which launches a real database (MySQL, PostgreSQL…) in a Docker container for the duration of integration tests;
  • Spring Boot testing tools ([@SpringBootTest], [MockMvc]) for testing a web service without deploying it.

14.5. Performance

A Kotlin program is executed by the Java Virtual Machine (JVM): it benefits from just-in-time compilation and runtime optimizations, with performance equivalent to that of a Java program. Among the tools that go a step further:

  • the JMH tool (“Java Microbenchmark Harness”), which can be used directly in Kotlin or via the kotlinx-benchmark Gradle plugin, to precisely measure code performance while accounting for virtual machine warm-up;
  • JDK Flight Recorder and JDK Mission Control, which record and analyze a program’s behavior in production; IntelliJ IDEA includes a profiler and a coroutine debugger;
  • ahead-of-time compilation to native code with GraalVM Native Image: a standalone executable that launches in a few milliseconds, at the cost of restrictions on reflection; Spring Boot and Quarkus can generate such executables from Kotlin code;
  • the choice of garbage collector (G1 by default, ZGC for very short pauses on large memory heaps).

14.6. Deployment

A Kotlin program is deployed just like a Java program: as a [.jar] archive executed by a JDK installed on the machine ([java -jar application.jar]), provided that the standard Kotlin library is included (this is what the scripts generated by [gradlew installDist] do, Chapter 2; Spring Boot generates a standalone [.jar] that contains all its libraries), as a standalone application that embeds a virtual machine reduced to only what it needs (tools [jlink] and [jpackage] from JDK), or in a Docker container (Spring Boot directly generates a container image via [gradlew bootBuildImage]).

14.7. Resources