Book Image

Kotlin Quick Start Guide

By : Marko Devcic
Book Image

Kotlin Quick Start Guide

By: Marko Devcic

Overview of this book

Kotlin is a general purpose, object-oriented language that primarily targets the JVM and Android. Intended as a better alternative to Java, its main goals are high interoperability with Java and increased developer productivity. Kotlin is still a new language and this book will help you to learn the core Kotlin features and get you ready for developing applications with Kotlin. This book covers Kotlin features in detail and explains them with practical code examples.You will learn how to set up the environment and take your frst steps with Kotlin and its syntax. We will cover the basics of the language, including functions, variables, and basic data types. With the basics covered, the next chapters show how functions are first-class citizens in Kotlin and deal with the object-oriented side of Kotlin. You will move on to more advanced features of Kotlin. You will explore Kotlin's Standard Library and learn how to work with the Collections API. The book finishes by putting Kotlin in to practice, showing how to build a desktop app. By the end of this book, you will be confident enough to use Kotlin for your next project.
Table of Contents (15 chapters)
Title Page
Copyright and Credits
Packt Upsell

Chapter 1. Introducing Kotlin

Kotlin is a relatively new programming language, developed by JetBrains, the company that stands behind some of the most popular developer IDEs and tools, such as IntelliJ IDEA and ReSharper. JetBrains didn't create Kotlin so that they could make money on it; instead, they started the project because they wanted to solve their own development problems. In 2010, when the project started, Java was the dominant language in their code base. However, the development team wasn't happy with Java and some of its old-fashioned features. They looked for more modern alternatives to Java, but couldn't find one that satisfied their requirements in the existing JVM languages. Scala was popular at the time and was considered, but it had issues such as slow compile times.

So, they decided to create a completely new language by themselves. Since they already had a huge code base written in Java, rewriting everything in this new language wouldn't have been practical. So, Java interoperability was one of the top priorities.

Preview of the language was released in 2011 and the developer community reacted positively to it. Since then, the popularity of the language has grown rapidly. The language is open source and JetBrains' developers are not the only ones working on it. The project (language, compiler, standard library, tools, and so on) is hosted on GitHub and developers all around the world are contributing to it. Currently, there around 200 contributors to the Kotlin repository. Developers are also adopting it and more and more companies are using it in their production code. Even big companies, such as Atlassian, Square, Uber, and Pinterest, use Kotlin in production. Google also supports Kotlin development. It made Kotlin an officially supported language for building Android apps.

Now that we know how Kotlin started – and that its main goals are great Java interoperability and, at the same time, better productivity than Java – we can say that Kotlin is a general purpose, statically typed, object-oriented and functional programming language, that (primarily) targets JVM. The name Kotlin comes from an island near St.Petersburg, just as Java was named after an island in Indonesia.

In this chapter we will focus on:

  • Compiling and running Kotlin
  • Kotlin's uses
  • Java interoperability
  • Build tools
  • Setting up the development environment