chapter one

1 Kotlin: what and why

 

This chapter covers:

  • A basic demonstration of Kotlin
  • The main traits of the Kotlin language
  • Possibilities for server-side and Android development
  • What distinguishes Kotlin from other languages
  • Writing and running code in Kotlin

What is Kotlin all about? It’s a modern programming language on the JVM and beyond. Kotlin is concise, safe, pragmatic, and provides full interoperability with Java code. Independent programmers, small software shops, and large enterprises all have embraced Kotlin: Millions of developers are now using it to build server-side applications, write Android apps, build desktop software, and more. Its use already spans many industries, whether it’s banking, education, video streaming or automotive, to name just a few. Kotlin enjoys an excellent ecosystem of libraries on the JVM, and code written in Kotlin runs as fast as you would expect from a modern programming language.

Over 200 universities worldwide include Kotlin as part of their curriculum in some capacity. Some of these universities even use the language to teach fundamental programming concepts to their students, including beginners who have never programmed before.

In this chapter, we’ll take a detailed look at Kotlin’s main traits.

1.1 A taste of Kotlin

1.2 Kotlin’s primary traits

1.2.1 Target platforms: server-side, Android, anywhere Java runs, and more

1.2.2 Static typing makes Kotlin performant, reliable, and maintainable

1.2.3 Combining functional and object-oriented makes Kotlin safe and flexible

1.2.4 Concurrent and asynchronous code becomes natural and structured with coroutines

1.2.5 Kotlin can be used for any purpose: it’s free and open source

1.3 Areas in which Kotlin is often used

1.3.1 Powering backends: server-side development with Kotlin

1.3.2 Mobile Development: Android is Kotlin-first

1.3.3 Multiplatform: Sharing business logic and minimizing duplicate work on iOS, JVM, JS and beyond

1.4 The philosophy of Kotlin

1.4.1 Kotlin is a pragmatic language designed to solve real-world problems