Kotlin (/ˈkɒtlɪn/)[2] is a cross-platform, statically typed, general-purpose high-level programming language with type inference. Kotlin is designed to interoperate fully with Java, and the JVM version of Kotlin's standard library depends on the Java Class Library,[3][failed verification] 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[4]) or native code via LLVM (e.g., for native iOS apps sharing business logic with Android apps).[5] Language development costs are borne by JetBrains, while the Kotlin Foundation protects the Kotlin trademark.[6]
On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers.[7] Since the release of Android Studio 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,[8] 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 support) is considered beta since version 1.3.[9][10]
In July 2011, JetBrains unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.[11] 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 time of Scala as a deficiency.[11] 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.[12]
The name comes from Kotlin Island, near St. Petersburg. Andrey Breslav mentioned that the team decided to name it after an island, just like Java was named after the Indonesian island of Java[13] (though the programming language Java was perhaps named after the coffee rather than the island).[14]
JetBrains hoped that the new language will drive IntelliJ IDEA sales.[15]
The first commit to the Kotlin Git repository was on November 8, 2010.[16]
Kotlin 1.0 was released on February 15, 2016.[17] 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 2017, Google announced first-class support for Kotlin on Android.[18]
Kotlin 1.2 was released on November 28, 2017.[19] Sharing code between JVM and JavaScript platforms feature was newly added to this release (as of version 1.4 multiplatform programming is an alpha feature[20] upgraded from "experimental"). A full-stack demo has been made with the new Kotlin/JS Gradle Plugin.[21][22]
Kotlin 1.3 was released on 29 October 2018, bringing coroutines for asynchronous programming.[23]
On 7 May 2019, Google announced that the Kotlin programming language is now its preferred language for Android app developers.[7]
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.[24]
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 version of the new Kotlin K2 compiler.[25]
Kotlin 1.8 was released in December 2022.
Development lead Andrey Breslav has said that Kotlin is designed to be an industrial-strength object-oriented language, and a "better language" than Java, but still be fully interoperable with Java code, allowing companies to make a gradual migration from Java to Kotlin.[26]
Semicolons are optional as a statement terminator; in most cases a newline is sufficient for the compiler to deduce that the statement has ended.[27]
Kotlin variable declarations and parameter lists have the data type come after the variable name (and with a colon separator), similar to Ada, BASIC, Pascal, TypeScript and Rust. 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.[28][29]
Variables in Kotlin can be read-only, declared with the val keyword, or mutable, declared with the var keyword.[30]
Class members are public by default, and classes themselves are final by default, meaning that creating a derived class is disabled unless the base class is declared with the open keyword.
In addition to the classes and member functions (which are equivalent to methods) of object-oriented programming, Kotlin also supports procedural programming with the use of functions.[31] Kotlin functions and constructors support default arguments, 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,[32] which are stable for the standard library declarations, but still experimental for user-defined declarations. Contracts are inspired by Eiffel's design by contract[33] programming paradigm.
Kotlin code may be compiled to JavaScript, 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.[34]
// Hello, World! example
fun main() {
val scope = "World"
println("Hello, $scope!")
}
fun main(args: Array<String>) {
for (arg in args)
println(arg)
}
Copyright © 2021 - 2024 NeXTech Corporation. All Rights Reserved
NeXTech Founded in 12 July 2018