Kotlin is a statically typed programming language that compiles to JVM bytecode, JavaScript, or native binaries.

Kotlin is an OSS statically typed programming language that runs on the JVM and also can be compiled to JavaScript or directly to native binaries. The language is inspired by existing languages such as Java, C#, JavaScript, Scala, and Groovy. It's developed by JetBrains.

Background

Kotlin is an OSS statically typed programming language that targets the JVM, Android, JavaScript, and Native. It's developed by JetBrains. The project started in 2010 and was open source from early on. The first official 1.0 release was in February 2016.

It has both object-oriented and functional constructs, which gives the developer the possibility to use it in both OO and FP styles or even mix elements of the two.

The language is 100% interoperable with the Java programming language and major emphasis has been placed on making sure that existing code can interact properly with Kotlin.

As Java can only be run directly by very few computers the first step to do before using Kotlin is to download the Java environment which is normally made available by installing a suitable software component.

Some main advantages that Kotlin has over Java is that null references are controlled by the type system, no checked exceptions, extension functions, data classes and the fact arrays in Kotlin are invariant.

Versions

Notable Kotlin versions and release dates include:

Kotlin 1.0                (February 15, 2016)
Kotlin 1.1                (March 1, 2017)
Kotlin/Native v0.1        (April 4, 2017)
Kotlin 1.2 [Early access] (June 27, 2017)

To see release notes for each version of Kotlin, visit the blog page on the releases.

The End Of Public Updates (formerly called End Of Life) dates are:

Kotlin 1.0.x - April 4, 2017

Initial help

Naming conventions

Kotlin programs should adhere to the following naming conventions to increase the readability and decrease the chance of accidental errors. By following these conventions, you will make it easier for the community to understand your code and help you.

  • Type names (classes, interfaces, enums, etc.) should begin with a capital letter and capitalize the first letter of each subsequent word. Examples include: Int, NoSuchFileException, and ByteArray. This is called PascalCase.
  • Method names should be camelCased; what means, that they begin with a lowercase letter and capitalize the first letter of each subsequent word. Examples: count, copyOf, filter.
  • Field names should be camelCased just like the method names.
  • Values of an Enum class should be written in ALL_CAPS with underscores separating each word. Examples: WARNING, SYNCHRONIZED, BOTTON_UP.

Hello World

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

A package-level function main which returns Unit and takes in an Array of strings as a parameter is defined. In it the method println(string : String) prints Hello, world! to the console.

Compilation of Hello World and running it:

$ kotlinc HelloWorld.kt -include-runtime -d HelloWorld.jar
$ java -jar HelloWorld.jar

The first line creates a .jar file that is self-contained and runnable by including the Kotlin runtime library in it.

More information:

Beginners' resources

Day-to-day resources

Books and other resources

  • Kotlin in Action (Some free chapters)
  • YouTube - This search for "Kotlin on Android" provides a variety of high-quality technical talks.

Social channels