Kotlin History Syntax References
Home Search



Kotlin - Langpedia

Kotlin


Website:

Kotlin

Designed by: Andrey Breslav, JetBrains

Developer: JetBrains

First appeared: July 2011, 14 years ago

Platforms: Android, JVM, iOS, iPadOS, tvOS, watchOS, macOS, Linux, Windows, JavaScript, WebAssembly, LLVM

License: Apache 2.0

Filename extensions: .kt, .kts, .kexe, .klib

Kotlin

Kotlin is a cross-platform, statically-typed, high-level programming language. Kotlin is designed to be fully compatiable with Java. Kotlin primarily runs on the JVM, although also compiles to JavaScript or native code via LLVM.

On May 7, 2019, Google announced Kotlin was its preferred langauge for Android app developers. Since the release of Android Studio 3.0, Kotlin has been included as an alternative to the standard Java compiler.

History

Name

The name comes from Kotlin Island, a Russian island in the Gulf of Finland, near St. Petersburg. The team decided to name it after an island, in immitation of the Java programming language, which shares the name of the Indonesian island of Java.

Development

In July 2011, JetBrains unveiled Project Kotlin, a new JVM language they'd been working on for over a year. JetBrains lead Dmitry Jemerov said that most languages lacked the features they were looking for, except for Scala, although, it had slow compiling time.

In February 2012, JetBrains open-sourced the project until the Apache 2.0 license.

Kotlin 1.0 was released on February 15, 2016, the first officially stable release, which JetBrains has promised long-term backwards compatibility starting with this version.

Syntax

Main entry point

Like in many other programming languages, the entry point to a Kotlin program is a function named main, which may be passed an array containing command line arguments. This is optional since Kotlin 1.3.

fun main(args: Array<String>) {
    for (arg in args) {
        println(arg)
    }
}

Visibility modifiers

Kotlin provides the following keywords to restrict visibility for top-level declarations and for class members: public, internal, protected, and private.

When applied to a class member:
Public - Visibility: Everywhere
Internal - Visibility: Within a module
Protected - Visibility: Within subclasses
Private - Visibility: Within a class

When applied to a top-level declaration:
Public - Visibility: Everywhere
Internal - Visibility: Within a module
Private - Visibility: Within a file

Null safety

Kotlin distinguishes between nullable and non-nullable data types. All nullable objects must be declared with a postfix of ? after the type name.

For these variables, a null-check must be performed before accessing the value by using:

- ?. (the safe navigation operator). If the object is null, the method won't be called, and the expression will be null. Example:

foo()?.bar()?.baz()

- ?: (the null coalescing operator) returns the first operand, if non-null, otherwise, returns the second operand.

val name: String = maybe ?: "stranger"

Lambdas

Kotlin supports lambdas, they are declared using braces. If it takes parameters, they are declared within the braces and followed by the -[GT] operator.

val l = { c : Any? -> println(c) }
val l2 = { print("no parameters") }

References

En Wikipedia Org. (2026). Kotlin. https://en.wikipedia.org/wiki/Kotlin. Retrieved August 7, 2026.



All Langpedia content is licensed under the Creative Commons Attribution-ShareAlike 4.0 License.