Kotlin (programming language)

Kotlin is designed to interoperate fully with Java, and the JVM version of Kotlin's standard library depends on the Java Class Library, but type inference allows its syntax to be more concise.

Kotlin mainly targets the JVM, but also compiles to JavaScript (e.g., for frontend web applications using React)[3] or native code via LLVM (e.g., for native iOS apps sharing business logic with Android apps).

[6] Since the release of Android Studio 3.0 in October 2017, Kotlin has been included as an alternative to the standard Java compiler.

Kotlin has support for the web with Kotlin/JS, through an intermediate representation-based backend which has been declared stable since version 1.8, released December 2022.

Andrey Breslav, Kotlin's former lead designer, mentioned that the team decided to name it after an island, in imitation of the Java programming language which shares a name with the Indonesian island of Java.

[10] In July 2011, JetBrains unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.

[15] This is considered to be the first officially stable release and JetBrains has committed to long-term backwards compatibility starting with this version.

[6] Kotlin 1.4 was released in August 2020, with e.g. some slight changes to the support for Apple's platforms, i.e. to the Objective-C/Swift interop.

This, according to an article from Roman Elizarov, current project lead, results in alignment of variable names and is more pleasing to eyes, especially when there are a few variable declarations in succession, and one or more of the types is too complex for type inference, or needs to be declared explicitly for human readers to understand.

[29][30] The influence of Scala in Kotlin can be seen in the extensive support for both object-oriented and functional programming[31] and in a number of specific features: Kotlin 1.3 added support for contracts,[32] which are stable for the standard library declarations, but still experimental for user-defined declarations.

[34] Kotlin relaxes Java's restriction of allowing static methods and variables to exist only within a class body.

As in C, C++, C#, Java, and Go, the entry point to a Kotlin program is a function named "main", which may be passed an array containing any command-line arguments.

[36] Similar to Python, the spread operator asterisk (*) unpacks an array's contents as individual arguments to a function, e.g.: Destructuring declarations decompose an object into multiple variables at once, e.g. a 2D coordinate object might be destructured into two integers, x and y.

This argument list supports an expanded syntax on Kotlin's standard function argument lists that enables declaration of class properties in the primary constructor, including visibility, extensibility, and mutability attributes.

Additionally, when defining a subclass, properties in super-interfaces and super-classes can be overridden in the primary constructor.

Operations on nullable objects need special care from developers: a null-check must be performed before using the value, either explicitly, or with the aid of Kotlin's null-safe operators: Kotlin provides support for higher-order functions and anonymous functions, or lambdas.

Kotlin on Android is seen as beneficial for its null-pointer safety, as well as for its features that make for shorter, more readable code.

[50] In addition to Spring, JetBrains has produced a Kotlin-first framework called Ktor for building web applications.

[52] In 2018, Kotlin was the fastest growing language on GitHub, with 2.6 times more developers compared to 2017.

A 2D picture of the Kotlin mascot
A 3D picture of the Kotlin mascot