9 Kotlin

 

This chapter covers

  • Why Kotlin?
  • Convenience and conciseness
  • Safety
  • Concurrency
  • Java Interoperability

Kotlin is a language created by JetBrains, makers of the popular IntelliJ IDEA. Announced publicly in 2011, Kotlin aims to fill language gaps they felt developing in Java, without the friction they saw with other existing JVM languages.

Kotlin was open-sourced the following year, and reached 1.0 - with guaranteed levels of support and maintenance from JetBrains - in 2016. Since then, it has gone on to become the recommended language for the Android platform and gathered a solid following in other JVM coding circles. The Kotlin Foundation, announced in 2018, brings the support of both JetBrains and Google to the language for the long term. Kotlin is even reaching beyond the JVM to support JavaScript and native backends.

9.1 Why Kotlin?

As alternate languages go, Kotlin provides many quality of life improvements over Java, while not radically changing the entire world. Its focus on convenience, safety, and solid interop has given it a great story for incremental usage in existing Java projects. With first-class support in IntelliJ IDEA, turning a file from Java to Kotlin is often just a click away.

9.1.1 Installing

9.2 Convenience and conciseness

9.2.1 Starting with less

9.2.2 Variables

9.2.3 Equality

9.2.4 Functions

9.2.5 Collections

9.2.6 Express yourself

9.3 A different view of classes and objects

9.3.1 Data classes

9.4 Safety

9.4.1 Null safety

9.4.2 Smart casting

9.5 Concurrency

9.6 Java interoperability

9.7 Summary

sitemap