Open main menu

Wikipedia β

Kotlin (programming language)

Kotlin is a statically-typed programming language that runs on the Java virtual machine and also can be compiled to JavaScript source code or use the LLVM compiler infrastructure. Its primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia.[3] While the syntax is not compatible with Java, Kotlin is designed to interoperate with Java code and is reliant on Java code from the existing Java Class Library, such as the collections framework.

Kotlin
Kotlin Logo
Designed by JetBrains
Developer JetBrains and open source contributors
First appeared 2011
Stable release
Kotlin 1.1.60 / November 13, 2017; 3 days ago (2017-11-13)[1]
Preview release
Kotlin 1.2 RC / November 2, 2017; 14 days ago (2017-11-02)[2]
Typing discipline static, inferred
Platform Outputs Java virtual machine bytecode and JavaScript source code
OS Any supporting JVM or JavaScript interpreter
License Apache 2
Filename extensions .kt, .kts
Website kotlinlang.org
Influenced by
Java, Scala, Groovy, C#, Gosu, JavaScript, Swift

As of Android Studio 3.0 (Beta version) Kotlin is a fully supported programming language on Android[4] and lets the user choose between targeting Java 6- or Java 8-compatible bytecode.[5]

Contents

HistoryEdit

In July 2011 JetBrains unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.[6] 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 compile time of Scala as an obvious deficiency.[6] 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.[7]

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[8] (though the programming language Java was perhaps named after the coffee.[9])

JetBrains hopes that the new language will drive IntelliJ IDEA sales.[10]

Kotlin v1.0 was released on February 15, 2016.[11] 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.[4]

PhilosophyEdit

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.[12]

SyntaxEdit

Kotlin variable declarations and parameter lists have the data type come after the variable name (and with a colon separator), similar to Pascal. As in Scala and Apache Groovy, semicolons are optional as a statement terminator; in most cases a newline is sufficient for the compiler to deduce that the statement has ended.[13]

SemanticsEdit

In addition to the classes and methods (called member functions in Kotlin) of object-oriented programming, Kotlin also supports procedural programming with the use of functions.[14] As in C and C++, the entry point to a Kotlin program is a function named "main", which is passed an array containing any command line arguments. Perl and Unix/Linux shell script-style string interpolation is supported. Type inference is also supported.

Hello, world! example

1 fun main(args: Array<String>) {
2   val scope = "world"
3   println("Hello, $scope!")
4 }

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:

fun sayHello(maybe: String?, neverNull: Int) {
   // use of elvis operator
   val name: String = maybe ?: "stranger"
   println("Hello $name")
}

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()

ToolsEdit

ApplicationsEdit

One of the obvious applications of Kotlin is Android development. The platform was stuck on Java 7 for a while (with some contemporary language features made accessible through the use of Retrolambda[23] or the Jack toolchain[24]) and Kotlin introduces many improvements for programmers such as null-pointer safety, extension functions and infix notation. Accompanied by full Java compatibility and good IDE support (Android Studio[25]) it is intended to improve code readability, give an easier way to extend Android SDK classes and speed up development.[26]

Kotlin was announced as an official Android development language at Google I/O 2017. It became the third language fully supported for Android, in addition to Java and C++.[27]

AdoptionEdit

According to the Kotlin website, Prezi is using Kotlin in the backend.[28] DripStat has done a writeup of their experience with Kotlin.[29]

According to Jetbrains blog, Kotlin is used by Amazon Web Services, Pinterest, Coursera, Netflix, Uber, Square, Trello, Basecamp,[30] and others. Corda, a distributed ledger developed by a consortium of well-known banks (such as Goldman Sachs, Wells Fargo, J.P. Morgan, Deutsche Bank, UBS, HSBC, BNP Paribas, Société Générale), has over 90% Kotlin in its codebase. [31]

According to Google, Kotlin has already been adopted by several major developers—Expedia, Flipboard, Pinterest, Square, and others—for their Android production apps.[32]

See alsoEdit

ReferencesEdit

  1. ^ "Kotlin 1.1.60 is out". Kotlin Blog. 2017-11-13. Retrieved 2017-11-15. 
  2. ^ https://blog.jetbrains.com/kotlin/2017/11/kotlinconf-keynote-recap/
  3. ^ Heiss, Janice (April 2013). "The Advent of Kotlin: A Conversation with JetBrains' Andrey Breslav". oracle.com. Oracle Technology Network. Retrieved February 2, 2014. 
  4. ^ a b Shafirov, Maxim (May 17, 2017). "Kotlin on Android. Now official". Today, at the Google I/O keynote, the Android team announced first-class support for Kotlin. 
  5. ^ "Kotlin FAQ". Kotlin lets you choose between generating Java 6 and Java 8 compatible bytecode. More optimal byte code may be generated for higher versions of the platform. 
  6. ^ a b Krill, Paul (Jul 22, 2011). "JetBrains readies JVM language Kotlin". infoworld.com. InfoWorld. Retrieved February 2, 2014. 
  7. ^ Waters, John (February 22, 2012). "Kotlin Goes Open Source". ADTmag.com/. 1105 Enterprise Computing Group. Retrieved February 2, 2014. 
  8. ^ Mobius (2015-01-08), Андрей Бреслав — Kotlin для Android: коротко и ясно, retrieved 2017-05-28 
  9. ^ https://www.javaworld.com/article/2077265/core-java/so-why-did-they-decide-to-call-it-java-.html
  10. ^ "Why JetBrains needs Kotlin". we expect Kotlin to drive the sales of IntelliJ IDEA 
  11. ^ "Kotlin 1.0 Released: Pragmatic Language for JVM and Android | Kotlin Blog". Blog.jetbrains.com. 2016-02-15. Retrieved 2017-04-11. 
  12. ^ "JVM Languages Report extended interview with Kotlin creator Andrey Breslav". Zeroturnaround.com. April 22, 2013. Retrieved February 2, 2014. 
  13. ^ "Semicolons". jetbrains.com. Retrieved February 8, 2014. 
  14. ^ "functions". jetbrains.com. Retrieved February 8, 2014. 
  15. ^ "Kotlin :: JetBrains Plugin Repository". Plugins.jetbrains.com. 2017-03-31. Retrieved 2017-04-11. 
  16. ^ "What's New in IntelliJ IDEA 2017.1". Jetbrains.com. Retrieved 2017-04-11. 
  17. ^ "Getting Started with Eclipse Neon - Kotlin Programming Language". Kotlinlang.org. 2016-11-10. Retrieved 2017-04-11. 
  18. ^ "JetBrains/kotlin-eclipse: Kotlin Plugin for Eclipse". GitHub. Retrieved 2017-04-11. 
  19. ^ "Using Maven - Kotlin Programming Language". kotlinlang.org. Retrieved 2017-05-09. 
  20. ^ "Using Ant - Kotlin Programming Language". kotlinlang.org. Retrieved 2017-05-09. 
  21. ^ "Using Gradle - Kotlin Programming Language". kotlinlang.org. Retrieved 2017-05-09. 
  22. ^ https://developer.android.com/kotlin/index.html
  23. ^ "orfjackal/retrolambda: Backport of Java 8's lambda expressions to Java 7, 6 and 5". GitHub. Retrieved 2017-05-09. 
  24. ^ "Jack (Java Android Compiler Kit) | Android Open Source Project". source.android.com. Retrieved 2016-04-15. 
  25. ^ "JetBrains Plugin Repository :: Kotlin". plugins.jetbrains.com. Retrieved 2016-04-15. 
  26. ^ "Will Kotlin Replace Java?". themindstudios.com. Retrieved 2017-03-10. 
  27. ^ "Kotlin Is Officially Joining The Android's Family, In Addition To Java And C++". Eyerys. May 18, 2017. Retrieved May 18, 2017. 
  28. ^ "Kotlin Programming Language". Kotlinlang.org. Retrieved 2017-04-11. 
  29. ^ "Kotlin in Production - What works, Whats broken". Blog.dripstat.com. 2016-09-24. Retrieved 2017-04-11. 
  30. ^ "How we made Basecamp 3's Android app 100% Kotlin – Signal v. Noise". Signal v. Noise. 2017-04-29. Retrieved 2017-05-01. 
  31. ^ "Kotlin 1.1 Released with JavaScript Support, Coroutines and more". Retrieved 2017-05-01. 
  32. ^ "Android Announces Support for Kotlin". 2017-05-17. Retrieved 2017-05-19. 

External linksEdit