Kotlin ()
is a
cross-platform
In computing, cross-platform software (also called multi-platform software, platform-agnostic software, or platform-independent software) is computer software that is designed to work in several computing platforms. Some cross-platform software r ...
,
statically typed,
general-purpose programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are a kind of computer language.
The description of a programming ...
with
type inference
Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistics ...
. Kotlin is designed to interoperate fully with
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
, and the
JVM
A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes ...
version of Kotlin's
standard library
In computer programming, a standard library is the library made available across implementations of a programming language. These libraries are conventionally described in programming language specifications; however, contents of a language's as ...
depends on the
Java Class Library
The Java Class Library (JCL) is a set of dynamically loadable libraries that Java Virtual Machine (JVM) languages can call at run time. Because the Java Platform is not dependent on a specific operating system, applications cannot rely on any of ...
,
but type inference allows its
syntax
In linguistics, syntax () is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure ( constituency) ...
to be more concise. Kotlin mainly targets the JVM, but also compiles to
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
(e.g., for frontend web applications using
React REACT or React may refer to:
Science and technology
*REACT (telescope), a telescope at Fenton Hill Observatory, New Mexico, US
Computing
* React (JavaScript library) , a JavaScript library for building user interfaces, from Facebook
** React Nati ...
) or
native code
In computer programming, machine code is any low-level programming language, consisting of machine language instructions, which are used to control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a ver ...
via
LLVM
LLVM is a set of compiler and toolchain technologies that can be used to develop a front end for any programming language and a back end for any instruction set architecture. LLVM is designed around a language-independent intermediate repre ...
(e.g., for native
iOS
iOS (formerly iPhone OS) is a mobile operating system created and developed by Apple Inc. exclusively for its hardware. It is the operating system that powers many of the company's mobile devices, including the iPhone; the term also include ...
apps sharing
business logic In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data can be created, stored, and changed. It is contrasted with the remainder of the software that might ...
with
Android apps). Language development costs are borne by
JetBrains
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Ams ...
, while the Kotlin Foundation protects the Kotlin trademark.
On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for
Android app developers.
Since the release of
Android Studio
Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. It is available for download on Windows ...
3.0 in October 2017, Kotlin has been included as an alternative to the standard Java compiler. The Android Kotlin compiler produces Java 8 bytecode by default (which runs in any later JVM), but lets the programmer choose to target Java 9 up to 18, for optimization,
or allows for more features; has bidirectional
record class interoperability support for JVM, introduced in Java 16, considered stable as of Kotlin 1.5.
Kotlin has support for the web; by compiling to JavaScript (i.e., Kotlin/JS with the classic back-end, is declared stable since version 1.3), while the newer Kotlin/JS (
IR-based) is in beta as of version 1.5.30. Kotlin/Native (for e.g.
Apple silicon
Apple silicon is a series of system on a chip (SoC) and system in a package (SiP) processors designed by Apple Inc., mainly using the ARM architecture. It is the basis of most new Mac computers as well as iPhone, iPad, iPod Touch, Apple TV, ...
support) is considered beta since version 1.3.
History
In July 2011,
JetBrains
JetBrains s.r.o. (formerly IntelliJ Software s.r.o.) is a Czech software development company which makes tools for software developers and project managers. , the company has offices in Prague; Munich; Berlin; Boston, Massachusetts; Ams ...
unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.
JetBrains lead Dmitry Jemerov said that most languages did not have the features they were looking for, with the exception of
Scala. However, he cited the slow
compilation
Compilation may refer to:
*In computer programming, the translation of source code into object code by a compiler
**Compilation error
**Compilation unit
*Product bundling, a marketing strategy used to sell multiple products
*Compilation thesis
M ...
time of Scala as a deficiency.
One of the stated goals of Kotlin is to compile as quickly as Java. In February 2012, JetBrains open sourced the project under the
Apache 2 license.
The name comes from
Kotlin Island, near
St. Petersburg
Saint Petersburg ( rus, links=no, Санкт-Петербург, a=Ru-Sankt Peterburg Leningrad Petrograd Piter.ogg, r=Sankt-Peterburg, p=ˈsankt pʲɪtʲɪrˈburk), formerly known as Petrograd (1914–1924) and later Leningrad (1924–1991), i ...
.
Andrey Breslav mentioned that the team decided to name it after an island, just like Java was named after the Indonesian island of
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
(though the programming language Java was perhaps named after the coffee rather than the island).
JetBrains hopes that the new language will drive
IntelliJ IDEA
IntelliJ IDEA is an integrated development environment (IDE) written in Java (programming language), Java for developing computer software written in Java, Kotlin (programming language), Kotlin, Groovy (programming language), Groovy, and other ...
sales.
The first commit to the Kotlin Git repository was on November 8, 2010.
Kotlin 1.0 was released on February 15, 2016. This is considered to be the first officially stable release and JetBrains has committed to long-term backwards compatibility starting with this version.
At
Google I/O
Google I/O (or simply I/O) is an annual developer conference held by Google in Mountain View, California. "I/O" stands for Input/Output, as well as the slogan "Innovation in the Open". The event's format is similar to Google Developer Day.
Hi ...
2017, Google announced first-class support for Kotlin on
Android.
Kotlin 1.2 was released on November 28, 2017. Sharing code between JVM and JavaScript platforms feature was newly added to this release (as of version 1.4 multiplatform programming is an
alpha
Alpha (uppercase , lowercase ; grc, ἄλφα, ''álpha'', or ell, άλφα, álfa) is the first letter of the Greek alphabet. In the system of Greek numerals, it has a value of one. Alpha is derived from the Phoenician letter aleph , whic ...
feature upgraded from "experimental"). A
full-stack demo has been made with the new Kotlin/JS Gradle Plugin.
Kotlin 1.3 was released on 29 October 2018, bringing coroutines for asynchronous programming.
On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers.
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
Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. Originally developed by Brad Cox and Tom Love in the early 1980s, it was selected by NeXT for its NeXTS ...
/
Swift
Swift or SWIFT most commonly refers to:
* SWIFT, an international organization facilitating transactions between banks
** SWIFT code
* Swift (programming language)
* Swift (bird), a family of birds
It may also refer to:
Organizations
* SWIFT, ...
interop
Interop is an annual information technology conference organised by Informa PLC. It takes place in the US and Tokyo (Japan) each year. 2016 marked Interop's (US) 30th anniversary and throughout that time, Interop has promoted interoperability and ...
.
Kotlin 1.5 was released in May 2021.
Kotlin 1.6 was released in November 2021.
Kotlin 1.7 was released in June 2022, including the
alpha
Alpha (uppercase , lowercase ; grc, ἄλφα, ''álpha'', or ell, άλφα, álfa) is the first letter of the Greek alphabet. In the system of Greek numerals, it has a value of one. Alpha is derived from the Phoenician letter aleph , whic ...
version of the new Kotlin K2
compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
.
Design
Development lead Andrey Breslav has said that Kotlin is designed to be an industrial-strength
object-oriented
Object-oriented programming (OOP) is a programming paradigm based on the concept of " objects", which can contain data and code. The data is in the form of fields (often known as attributes or ''properties''), and the code is in the form of p ...
language, and a "better language" than
Java
Java (; id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 151.6 million people, Java is the world's List ...
, but still be fully interoperable with Java code, allowing companies to make a gradual migration from Java to Kotlin.
Semicolon
The semicolon or semi-colon is a symbol commonly used as orthographic punctuation. In the English language, a semicolon is most commonly used to link (in a single sentence) two independent clauses that are closely related in thought. When a ...
s are optional as a
statement terminator
Terminator may refer to:
Science and technology
Genetics
* Terminator (genetics), the end of a gene for transcription
* Terminator technology, proposed methods for restricting the use of genetically modified plants by causing second generation s ...
; in most cases a
newline is sufficient for the
compiler
In computing, a compiler is a computer program that translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily used for programs that ...
to deduce that the statement has ended.
Kotlin
variable
Variable may refer to:
* Variable (computer science), a symbolic name associated with a value and whose associated value may be changed
* Variable (mathematics), a symbol that represents a quantity in a mathematical expression, as used in many ...
declarations and
parameter lists have the
data type
In computer science and computer programming, a data type (or simply type) is a set of possible values and a set of allowed operations on it. A data type tells the compiler or interpreter how the programmer intends to use the data. Most progra ...
come after the variable name (and with a
colon separator), similar to
Ada
Ada may refer to:
Places
Africa
* Ada Foah, a town in Ghana
* Ada (Ghana parliament constituency)
* Ada, Osun, a town in Nigeria
Asia
* Ada, Urmia, a village in West Azerbaijan Province, Iran
* Ada, Karaman, a village in Karaman Province, ...
,
BASIC
BASIC (Beginners' All-purpose Symbolic Instruction Code) is a family of general-purpose, high-level programming languages designed for ease of use. The original version was created by John G. Kemeny and Thomas E. Kurtz at Dartmouth College ...
,
Pascal,
TypeScript
TypeScript is a free and open source programming language
A programming language is a system of notation for writing computer programs. Most programming languages are text-based formal languages, but they may also be graphical. They are ...
and
Rust
Rust is an iron oxide, a usually reddish-brown oxide formed by the reaction of iron and oxygen in the catalytic presence of water or air moisture. Rust consists of hydrous iron(III) oxides (Fe2O3·nH2O) and iron(III) oxide-hydroxide (FeO(OH ...
. 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.
Variables in Kotlin can be read-only, declared with the keyword, or
mutable
In object-oriented and functional programming, an immutable object (unchangeable object) is an object whose state cannot be modified after it is created.Goetz et al. ''Java Concurrency in Practice''. Addison Wesley Professional, 2006, Section 3 ...
, declared with the keyword.
Class members are public by default, and classes themselves are
final
Final, Finals or The Final may refer to:
*Final (competition), the last or championship round of a sporting competition, match, game, or other contest which decides a winner for an event
** Another term for playoffs, describing a sequence of cont ...
by default, meaning that creating a derived class is disabled unless the base class is declared with the keyword.
In addition to the
classes and
member functions (which are equivalent to methods) of object-oriented programming, Kotlin also supports
procedural programming
Procedural programming is a programming paradigm, derived from imperative programming, based on the concept of the '' procedure call''. Procedures (a type of routine or subroutine) simply contain a series of computational steps to be carrie ...
with the use of
functions.
Kotlin functions and constructors support
default argument
In computer programming, a default argument is an argument to a function that a programmer is not required to specify.
In most programming languages, functions may take one or more arguments. Usually, each argument must be specified in full (this ...
s,
variable-length argument lists,
named arguments and overloading by unique signature. Class member functions are virtual, i.e. dispatched based on the runtime type of the object they are called on.
Kotlin 1.3 added support for contracts, which are stable for the standard library declarations, but still experimental for user-defined declarations. Contracts are inspired by
Eiffel's design by contract programming paradigm.
Kotlin code may be compiled to
JavaScript
JavaScript (), often abbreviated as JS, is a programming language that is one of the core technologies of the World Wide Web, alongside HTML and CSS. As of 2022, 98% of Website, websites use JavaScript on the Client (computing), client side ...
, allowing for interoperability between code written in the two languages. This can be used either to write full web applications in Kotlin, or to share code between a Kotlin backend and a JavaScript frontend.
Syntax
Procedural programming style
Kotlin relaxes Java's restriction of allowing
static
Static may refer to:
Places
*Static Nunatak, a nunatak in Antarctica
United States
* Static, Kentucky and Tennessee
*Static Peak, a mountain in Wyoming
**Static Peak Divide, a mountain pass near the peak
Science and technology Physics
*Static el ...
methods and variables to exist only within a class body. Static objects and functions can be defined at the top level of the package without needing a redundant class level. For compatibility with Java, Kotlin provides a
JvmName
annotation which specifies a class name used when the package is viewed from a Java project. For example,
@file:JvmName("JavaClassName")
.
Main entry point
As in
C,
C++
C++ (pronounced "C plus plus") is a high-level general-purpose programming language created by Danish computer scientist Bjarne Stroustrup as an extension of the C programming language, or "C with Classes". The language has expanded significan ...
,
C#, Java, and
Go, the
entry point
In computer programming
Computer programming is the process of performing a particular computation (or more generally, accomplishing a specific computing result), usually by designing and building an executable computer program. Programmin ...
to a Kotlin
program
Program, programme, programmer, or programming may refer to:
Business and management
* Program management, the process of managing several related projects
* Time management
* Program, a part of planning
Arts and entertainment Audio
* Progra ...
is a function named "main", which may be passed an array containing any
command-line
A command-line interpreter or command-line processor uses a command-line interface (CLI) to receive commands from a user in the form of lines of text. This provides a means of setting parameters for the environment, invoking executables and pro ...
arguments. This is optional since Kotlin 1.3.
Perl
Perl is a family of two high-level, general-purpose, interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it also referred to its redesigned "sister language", Perl 6, before the latter's name was offici ...
,
PHP
PHP is a general-purpose scripting language geared toward web development. It was originally created by Danish-Canadian programmer Rasmus Lerdorf in 1993 and released in 1995. The PHP reference implementation is now produced by The PHP Group. ...
and
Unix shell
A Unix shell is a command-line Interpreter (computing), interpreter or shell (computing), shell that provides a command line user interface for Unix-like operating systems. The shell is both an interactive command language and a scripting langua ...
style
string interpolation is supported.
Type inference
Type inference refers to the automatic detection of the type of an expression in a formal language. These include programming languages and mathematical type systems, but also natural languages in some branches of computer science and linguistics ...
is also supported.
// Hello, World! example
fun main()
fun main(args: Array)
Extension functions
Similar to C#, Kotlin allows adding an
extension function to any class without the formalities of creating a derived class with new functions. An extension function has access to all the public interface of a class, which it can use to create a new function interface to a target class. An extension function will appear exactly like a function of the class and will be shown in code completion inspection of class functions. For example:
package MyStringExtensions
fun String.lastChar(): Char = get(length - 1)
>>> println("Kotlin".lastChar())
By placing the preceding code in the top-level of a package, the String class is extended to include a function that was not included in the original definition of the String class.
// Overloading '+' operator using an extension function
operator fun Point.plus(other: Point): Point
>>> val p1 = Point(10, 20)
>>> val p2 = Point(30, 40)
>>> println(p1 + p2)
Point(x=40, y=60)
Unpack arguments with spread operator
Similar to Python, the spread operator asterisk (*) unpacks an array's contents as comma-separated arguments to a function:
fun main(args: Array)
Destructuring declarations
''Destructuring declarations'' decompose an object into multiple variables at once, e.g. a 2D coordinate object might be ''destructured'' into two integers, and .
For example, the object supports destructuring to simplify access to its key and value fields:
for ((key, value) in map)
println("$key: $value")
Nested functions
Kotlin allows local functions to be declared inside of other functions or methods.
class User(val id: Int, val name: String, val address: String)
fun saveUserToDb(user: User)
Classes are final by default
In Kotlin, to derive a new class from a base class type, the base class needs to be explicitly marked as "open". This is in contrast to most object-oriented languages such as Java where classes are open by default.
Example of a base class that is open to deriving a new subclass from it.
// open on the class means this class will allow derived classes
open class MegaButton
class GigaButton: MegaButton()
Abstract classes are open by default
Abstract class
In programming languages, an abstract type is a type in a nominative type system that cannot be instantiated directly; a type that is not abstract – which ''can'' be instantiated – is called a ''concrete type''. Every instance of an abstra ...
es define abstract or "pure virtual" placeholder functions that will be defined in a derived class. Abstract classes are open by default.
// No need for the open keyword here, it’s already open by default
abstract class Animated
Classes are public by default
Kotlin provides the following keywords to restrict visibility for top-level declaration, such as classes, and for class members:
public
,
internal
,
protected
, and
private
.
When applied to a class member:
When applied to a top-level declaration:
Example:
// Class is visible only to current module
internal open class TalkativeButton
internal class MyTalkativeButton: TalkativeButton()
MyTalkativeButton().utter()
Primary constructor vs. secondary constructors
Kotlin supports the specification of a "primary constructor" as part of the class definition itself, consisting of an argument list following the class name. 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.
// Example of class using primary constructor syntax
// (Only one constructor required for this class)
open class BaseUser(open var isSubscribed: Boolean)
open class PowerUser(protected val nickname: String, final override var isSubscribed: Boolean = true):BaseUser(isSubscribed)
However, in cases where more than one constructor is needed for a class, a more general constructor can be used called secondary constructor syntax which closely resembles the constructor syntax used in most object-oriented languages like C++, C#, and Java.
// Example of class using secondary constructor syntax
// (more than one constructor required for this class)
class Context
class AttributeSet
open class View(ctx:Context)
class MyButton : View
Sealed classes
The Sealed classes and interfaces restrict the subclass hierarchies, meaning more control over the inheritance hierarchy.
Declaration of sealed interface and class:
sealed interface Expr
sealed class Job
All the subclasses of the sealed class are defined at compile time.
No new subclasses can be added to it after the compilation of the module having the sealed class.
For example, a sealed class in a compiled jar file cannot be subclassed.
sealed class Vehicle
data class Car(val brandName: String, val owner: String, val color: String): Vehicle()
class Bike(val brandName: String, val owner: String, val color: String): Vehicle()
class Tractor(val brandName: String, val owner: String, val color: String): Vehicle()
val kiaCar = Car("KIA", "John", "Blue")
val hyundaiCar = Car("Hyundai", "Britto", "Green")
Data classes
Kotlin's
data class
construct defines classes whose primary purpose is storing data. This construct is similar to normal classes except that the key functions
equals
,
toString
, and
hashCode
are automatically generated from the class properties. In Java, such classes are expected to provide a standard assortment of functions such as those. Data classes are not required to declare any methods, though each must have at least one property. A data class often is written without a body, though it is possible to give a data class any methods or secondary constructors that are valid for any other class. The
data
keyword is used before the
class
keyword to define a data class.
// data class with parameters and their optional default values
data class Book(val name: String = "", val price: Int = 0)
fun main(args: Array)
Kotlin interactive shell
$ kotlinc-jvm
type :help for help; :quit for quit
>>> 2 + 2
4
>>> println("Hello, World!")
Hello, World!
Kotlin as a scripting language
Kotlin can also be used as a scripting language. A script is a Kotlin source file (.kts) with top level executable code.
// list_folders.kts
import java.io.File
val folders = File(args .listFiles
folders?.forEach(::println)
Scripts can be run by passing the
-script
option and the corresponding script file to the compiler.
$ kotlinc -script list_folders.kts "path_to_folder_to_inspect"
Null safety
Kotlin makes a distinction between
nullable and non-nullable data types. All nullable objects must be declared with a "?" postfix after the type name. Operations on nullable objects need special care from developers: null-check must be performed before using the value. Kotlin provides null-safe operators to help developers:
* (
safe navigation operator
In object-oriented programming, the safe navigation operator (also known as optional chaining operator, safe call operator, null-conditional operator, null-propagation operator) is a binary operator that returns null if its first argument is null; ...
) can be used to safely access a method or property of a possibly null object. If the object is null, the method will not be called and the expression evaluates to null.
* (
null coalescing operator
The null coalescing operator (called the Logical Defined-Or operator in Perl) is a binary operator that is part of the syntax for a basic conditional expression in several programming languages, including C#, PowerShell as of version 7.0.0, Perl a ...
) often referred to as the
Elvis operator
In certain computer programming languages, the Elvis operator, often written ?:, is a binary operator that returns its first operand if that operand evaluates to a true value, and otherwise evaluates and returns its second operand. This is identic ...
:
fun sayHello(maybe: String?, neverNull: Int)
An example of the use of the safe navigation operator:
// returns null if...
// - foo() returns null,
// - or if foo() is non-null, but bar() returns null,
// - or if foo() and bar() are non-null, but baz() returns null.
// vice versa, return value is non-null if and only if foo(), bar() and baz() are non-null
foo()?.bar()?.baz()
Lambdas
Kotlin provides support for
higher-order functions and
anonymous functions
In computer programming, an anonymous function (function literal, lambda abstraction, lambda function, lambda expression or block) is a function definition that is not bound to an identifier. Anonymous functions are often arguments being passed t ...
or lambdas.
// the following function takes a lambda, f, and executes f passing it the string "lambda"
// note that (String) -> Unit indicates a lambda with a String parameter and Unit return type
fun executeLambda(f: (String) -> Unit)
Lambdas are declared using braces, . If a lambda takes parameters, they are declared within the braces and followed by the operator.
// the following statement defines a lambda that takes a single parameter and passes it to the println function
val l =
// lambdas with no parameters may simply be defined using
val l2 =
Complex "hello world" example
fun main(args: Array)
// Inline higher-order functions
inline fun greet(s: () -> String) : String = greeting andAnother s()
// Infix functions, extensions, type inference, nullable types,
// lambda expressions, labeled this, Elvis operator (?:)
infix fun String.andAnother(other : Any?) = buildString()
// Immutable types, delegated properties, lazy initialization, string templates
val greeting by lazy
// Sealed classes, companion objects
sealed class to
// Extensions, Unit
fun String.print() = println(this)
Tools
*
IntelliJ IDEA
IntelliJ IDEA is an integrated development environment (IDE) written in Java (programming language), Java for developing computer software written in Java, Kotlin (programming language), Kotlin, Groovy (programming language), Groovy, and other ...
has plug-in support for Kotlin. IntelliJ IDEA 15 was the first version to bundle the Kotlin plugin in the IntelliJ Installer, and provide Kotlin support out of the box.
* JetBrains also provides a plugin for
Eclipse.
* Integration with common Java build tools is supported including
Apache Maven
Maven is a build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation, where it was ...
,
Apache Ant
Apache Ant is a software tool for automating software build processes which originated from the Apache Tomcat project in early 2000 as a replacement for the Make build tool of Unix. It is similar to Make, but is implemented using the Java languag ...
, and
Gradle
Gradle is a build automation tool for multi-language software development. It controls the development process in the tasks of compilation and packaging to testing, deployment, and publishing. Supported languages include Java (as well as Kotli ...
.
*
Android Studio
Android Studio is the official integrated development environment (IDE) for Google's Android operating system, built on JetBrains' IntelliJ IDEA software and designed specifically for Android development. It is available for download on Windows ...
(based on IntelliJ IDEA) has official support for Kotlin, starting from Android Studio 3.
*
Emacs has a Kotlin Mode in its MELPA package repository.
*
Vim has a plugin maintained on GitHub.
Json2Kotlingenerates
POJO style native Kotlin code for web service response mapping.
Applications
When Kotlin was announced as an official Android development language at
Google I/O
Google I/O (or simply I/O) is an annual developer conference held by Google in Mountain View, California. "I/O" stands for Input/Output, as well as the slogan "Innovation in the Open". The event's format is similar to Google Developer Day.
Hi ...
in May 2017, it became the third language fully supported for Android, in addition to Java and C++. As of 2020, Kotlin is still most widely used on Android, with Google estimating that 70% of the top 1000 apps on the Play Store are written in Kotlin. Google itself has 60 apps written in Kotlin, including Maps and Drive. Many Android apps, such as Google's Home, are in the process of being migrated to Kotlin, and so use both Kotlin and Java. 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.
In addition to its prominent use on Android, Kotlin is gaining traction in server-side development. The
Spring Framework
The Spring Framework is an application framework and inversion of control container for the Java platform. The framework's core features can be used by any Java application, but there are extensions for building web applications on top of the Java ...
officially added Kotlin support with version 5 on 4 January 2017. To further support Kotlin, Spring has translated all its documentation to Kotlin and added built-in support for many Kotlin-specific features such as coroutines. In addition to Spring, JetBrains has produced a Kotlin-first framework called Ktor for building web applications.
In 2020, JetBrains found in a survey of developers who use Kotlin that 56% were using Kotlin for mobile apps, while 47% were using it for a web back-end. Just over a third of all Kotlin developers said that they were migrating to Kotlin from another language. Most Kotlin users were targeting Android (or otherwise on the JVM), with only 6% using Kotlin Native.
Some of the main features of Kotlin include:
* Conciseness: Kotlin code is often much shorter than equivalent code written in Java, making it easier to write and maintain.
* Null safety: Kotlin has built-in support for null safety, which helps prevent null pointer exceptions and makes it easier to write safe code.
* Extension functions: Kotlin allows you to extend the functionality of existing classes by adding new functions to them, without having to inherit from them or use design patterns like decorators.
* Data classes: Kotlin has a built-in syntax for creating classes that hold data, which can be useful for storing simple data structures like records or database rows.
* Coroutines: Kotlin has a built-in support for coroutines, which are lightweight threads that can be used to perform asynchronous tasks without the overhead of traditional threads.
In terms of security, Kotlin provides several features that can help developers write secure code:
* Type safety: Kotlin's type system helps prevent type-related vulnerabilities, such as buffer overflows and SQL injection attacks.
* Access control: Kotlin's access control features allow you to specify which parts of your code are visible to other parts, helping to prevent unauthorized access to sensitive data.
* Safe calls: Kotlin's safe call operator (?.) allows you to safely access an object's methods and properties, without having to check for null values manually.
* Nullability annotations: Kotlin provides built-in annotations for specifying whether a value can be null or not, which can help prevent null reference exceptions and improve code readability.
Adoption
In 2018, Kotlin was the fastest growing language on GitHub with 2.6 times more developers compared to 2017. It is the fourth most loved programming language according to the 2020 Stack Overflow Developer Survey.
Kotlin was also awarded the O'Reilly Open Source Software Conference Breakout Award for 2019.
Many companies/organizations have used Kotlin for backend development:
* Google
* Norwegian Tax Administration
* Gradle
* Amazon
* Cash App
* JetBrains
* Flux
*
Allegro
Allegro may refer to:
Common meanings
* Allegro (music), a tempo marking indicate to play fast, quickly and bright
* Allegro (ballet), brisk and lively movement
Artistic works
* L'Allegro (1645), a poem by John Milton
* ''Allegro'' (Satie), an ...
* OLX
* Shazam
* Pivotal
* Rocket Travel
* Meshcloud
* Zalando
Some companies/organizations have used Kotlin for web development:
* JetBrains
* Data2viz
* Fritz2
* Barclay's Bank
A number of companies have publicly stated they were using Kotlin:
* DripStat
*
Basecamp
Mountaineering or alpinism, is a set of outdoor activities that involves ascending tall mountains. Mountaineering-related activities include traditional outdoor climbing, skiing, and traversing via ferratas. Indoor climbing, sport climbing, a ...
*
Pinterest
Pinterest is an American image sharing and social media service designed to enable saving and discovery of information (specifically "ideas") on the internet using images, and on a smaller scale, animated GIFs and videos, in the form of pinboard ...
* Coursera
* Netflix
* Uber
* Cash App
* Trello
* Duolingo
* Corda, a distributed ledger developed by a consortium of well-known banks (such as
Goldman Sachs
Goldman Sachs () is an American multinational investment bank and financial services company. Founded in 1869, Goldman Sachs is headquartered at 200 West Street in Lower Manhattan, with regional headquarters in London, Warsaw, Bangalore, H ...
,
Wells Fargo
Wells Fargo & Company is an American multinational financial services company with corporate headquarters in San Francisco, California; operational headquarters in Manhattan; and managerial offices throughout the United States and intern ...
,
J.P. Morgan,
Deutsche Bank
Deutsche Bank AG (), sometimes referred to simply as Deutsche, is a German multinational investment bank and financial services company headquartered in Frankfurt, Germany, and dual-listed on the Frankfurt Stock Exchange and the New York Sto ...
,
UBS,
HSBC,
BNP Paribas,
Société Générale
Société Générale S.A. (), colloquially known in English as SocGen (), is a French-based multinational financial services company founded in 1864, registered in downtown Paris and headquartered nearby in La Défense.
Société Générale ...
), has over 90% Kotlin code in its codebase.
See also
*
Comparison of programming languages
Programming languages are used for controlling the behavior of a machine (often a computer). Like natural languages, programming languages follow the rules for syntax and semantics.
There are thousands of programming languages and new ones are c ...
References
* This article contains quotations from Kotlin tutorials which are released under an Apache 2.0 license.
External links
*
{{Java (Sun)
2011 software
Free software projects
High-level programming languages
Java programming language family
JVM programming languages
Object-oriented programming languages
Programming languages
Programming languages created in 2011
Software using the Apache license
Statically typed programming languages
tk:Kotlin (programmirleme dili)