Skip to content
IT glossary
BackendUpdated December 3, 2026

Kotlin

Kotlin is a programming language used for backend services, Android apps, and other projects. It checks types before the program runs and can use Java libraries when running on the Java Virtual Machine (JVM).

Where Kotlin fits on the backend

Kotlin is a general-purpose, statically typed language. For a typical server application, the Kotlin compiler produces JVM bytecode, which runs on the same virtual machine as compiled Java. That makes Kotlin an option for a new service or for a single module in an existing Java application. A team can keep its Spring Boot setup and Java database libraries, for example, while writing new business logic in Kotlin. Ktor is another option for building HTTP services. Kotlin can also target JavaScript and native platforms, so the language itself is not tied to the JVM.

How the type system handles missing values

Static typing doesn't mean writing a type on every line. In val retries = 3, the compiler infers Int and still rejects an attempt to pass retries to a function that expects a String. Kotlin also checks whether a value can be absent: String does not allow null, but String? does.

Suppose an API returns a summary of an order whose shipping address has not necessarily been entered yet:

data class Address(val postalCode: String)
data class Order(val shippingAddress: Address?)

fun shippingLabel(order: Order): String =
    order.shippingAddress?.postalCode ?: "Address pending"

The safe-call operator ?. reads the postal code only if the address exists. Otherwise, the left side evaluates to null, so ?: supplies the fallback. Here the fallback is display text; it should not be treated as a real postal code when validating an order. The data modifier generates methods such as equals, hashCode, and copy from the properties declared in the primary constructor.

Common traps

  • A local val cannot be reassigned, but the object it refers to may still change. You can add items to a MutableList held in a val.
  • !! tells Kotlin to throw if the value is null. It is not a safe substitute for checking whether a value is present. Java interoperability deserves extra care: when a Java API does not specify nullability, the Kotlin compiler may let you use its result as non-null even though it can be null at runtime.
  • A suspend function can suspend a coroutine at a suspension point, letting its thread do other work while the coroutine is suspended. The modifier doesn't start a new thread or turn a blocking API into a non-blocking one. A blocking JDBC query still ties up the thread that runs it.

What interviewers look for

You may be asked to review a short request handler that assumes a database lookup always succeeds. Explain what happens if no row exists and whether the handler should return 404, use a default, or propagate an error. The decision depends on the API contract, not on which Kotlin operator makes the code shortest. For roles that use coroutines, expect to explain where a request can suspend and where it still blocks a thread.