Kotlin (programming language)

Kotlin
Designed by JetBrains
Developer JetBrains and open source contributors
Stable release
Kotlin 1.0.5 / November 8, 2016 (2016-11-08)[1]
Preview release
Kotlin 1.1-M03 / November 24, 2016 (2016-11-24)[2]
Typing discipline static, inferred
Platform Outputs Java Virtual Machine bytecode and JavaScript source code
OS any supporting a JVM or JavaScript interpreter
License Apache 2
Filename extensions .kt, .kts
Website kotlinlang.org
Influenced by
Java, Scala, Groovy, C#, Gosu

Kotlin is a statically-typed programming language that runs on the Java Virtual Machine and also can be compiled to JavaScript source code. Its primary development is from a team of JetBrains programmers based in Saint Petersburg, Russia (the name comes from the Kotlin Island, near St. Petersburg).[3] Kotlin was named Language of the Month in the January 2012 issue of Dr. Dobb's Journal.[4] While not syntax 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.

History

In July 2011 JetBrains unveiled Project Kotlin, a new language for the JVM, which had been under development for a year.[5] 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.[5] 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.[6] Jetbrains hopes that the new language will drive IntelliJ IDEA sales.[7]

Kotlin v1.0 was released on February 15, 2016.[8] This is considered to be the first officially stable release and JetBrains has committed to long-term backwards compatibility starting with this version.

Philosophy

Development lead Andrey Breslav has said that Kotlin is designed to be an industrial-strength object-oriented language, and to be a better language than Java but still be fully interoperable with Java code, allowing companies to make a gradual migration from Java to Kotlin.[9]

Syntax

Like Pascal, TypeScript, Haxe, PL/SQL, F#, Go and Scala—and unlike C and its derivatives such as C++, Java, C#, and D—Kotlin variable declarations and parameter lists have the data type come after the variable name (and with a colon separator). As in Scala and 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.[10]

Semantics

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

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

Kotlin makes a distinction between nullable and non-nullable datatypes. 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 is null, or bar() returns null, or baz() returns null
  foo ?. bar() ?. baz()

Tools

Applications

One of the obvious applications of Kotlin is Android development. The platform has been long stuck on Java 6 (note: retrolambda[16] and the transition to Jack compiler[17]) and Kotlin introduces many improvements for programmers such as null-pointer safety, extension functions and infix notation. Accompanied by 100% Java compatibility and good IDE support (Android Studio[18]) it gives an excellent way to improve code readability, extend Android SDK classes and speed up development.

Users

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

References

  1. https://blog.jetbrains.com/kotlin/2016/11/kotlin-1-0-5-is-here/
  2. https://blog.jetbrains.com/kotlin/2016/11/kotlin-1-1-m03-is-here/
  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. Breslav, Andrey (January 20, 2012). "Language of the Month: Kotlin". drdobbs.com. Retrieved February 2, 2014.
  5. 1 2 Krill, Paul (Jul 22, 2011). "JetBrains readies JVM language Kotlin". infoworld.com. InfoWorld. Retrieved February 2, 2014.
  6. Waters, John (February 22, 2012). "Kotlin Goes Open Source". ADTmag.com/. 1105 Enterprise Computing Group. Retrieved February 2, 2014.
  7. "Why JetBrains needs Kotlin". we expect Kotlin to drive the sales of IntelliJ IDEA
  8. Breslav, Andrey (February 15, 2016). "Kotlin 1.0 Released: Pragmatic Language for JVM and Android".
  9. RebelLabs (April 22, 2013). "JVM Languages Report extended interview with Kotlin creator Andrey Breslav". zeroturnaround.com. Retrieved February 2, 2014.
  10. "Semicolons". jetbrains.com. Retrieved February 8, 2014.
  11. "functions". jetbrains.com. Retrieved February 8, 2014.
  12. "Jetbrains Plugin Repository:Kotlin".
  13. https://www.jetbrains.com/idea/whatsnew/
  14. "Kotlin for Eclipse".
  15. 1 2 3 "Kotlin Build Tools".
  16. "orfjackal/retrolambda". GitHub. Retrieved 2016-04-15.
  17. "Jack (Java Android Compiler Kit) | Android Open Source Project". source.android.com. Retrieved 2016-04-15.
  18. "JetBrains Plugin Repository :: Kotlin". plugins.jetbrains.com. Retrieved 2016-04-15.
  19. "Project Kotlin". Kotlin in backend, data processing and service development
  20. "Kotlin in Production - What works, Whats broken".

External links

This article is issued from Wikipedia - version of the 11/30/2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.