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
Dedication
Packt Upsell
Contributors
Preface
Index

Preface

Kotlin is a relatively new language that is gaining popularity rapidly, thanks to its numerous unique features that increase developer productivity. It is primarily used for mobile (Android) and server-side (backend) development but can be used anywhere Java is used. Thanks to its other compiler, which transforms it into JavaScript, it can even be used for frontend web development. This book targets newcomers to the language and tries to bring them to intermediate-advanced levels of Kotlin knowledge. 

Who this book is for

This book covers the basic features of the language and its syntax, so no prior knowledge of Kotlin is required. You should have at least basic knowledge of general programming. You should know what control-flow statements, variables, classes, and basic data structures are.

What this book covers

Chapter 1, Introducing Kotlin, covers general features of the language and shows the reader how to install an IDE and the Kotlin compiler.

Chapter 2, Kotlin Basics, introduces the reader to the language syntax and explores the basic building blocks of the language: functions, variables, basic types, and so on.

Chapter 3, Classes and Object-Oriented Programming, focuses on the object-oriented features of the language. The chapter explores classes and interfaces and how they are extended and implemented. The chapter also shows some features that are specific to Kotlin, such as objects, companion objects, and sealed classes.

Chapter 4, Functions and Lambdas, shows how functions are first-class citizens in Kotlin. The chapter also shows Kotlin function features that are not present in Java, such as default argument values, named parameters, and function inlining.

Chapter 5, Advanced Kotlin, deals with more advanced features of Kotlin, such as operator overloading, generics, receiver functions, and constructs for multi-threaded programming.

Chapter 6, Kotlin Standard Library, shows some really useful functions that ship with Kotlin and also explores the Collections API.

 

Chapter 7, Coding a Dictionary App with Kotlin, is the chapter where we put Kotlin into practice. We summarize our learning from previous chapters and build a desktop dictionary application.

To get the most out of this book

Since Kotlin compiles to Java bytecode and uses Java's types and build tools (Maven and Gradle), readers with a Java background will probably find Kotlin a bit easier than those without. But a Java background is not a requirement, as this book is intended for readers who are completely new to Kotlin/Java and the JVM ecosystem. 

This book doesn't teach programming, so readers that have knowledge of any modern general-purpose programming language will find content in this book more understandable than those who don't.

Download the example code files

You can download the example code files for this book from your account at www.packtpub.com. If you purchased this book elsewhere, you can visit www.packtpub.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packtpub.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Kotlin-Quick-Start-Guide. In case there's an update to the code, it will be updated on the existing GitHub repository.

 

 

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: http://www.packtpub.com/sites/default/files/downloads/KotlinQuickStartGuide_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "Mount the downloaded WebStorm-10*.dmg disk image file as another disk in your system."

A block of code is set as follows:

<plugin>
   <artifactId>kotlin-maven-plugin</artifactId>
   <groupId>org.jetbrains.kotlin</groupId>
   <version>${kotlin.version}</version>
   <configuration>
      <jvmTarget>1.8</jvmTarget>
   </configuration>
</plugin>

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Select System info from the Administration panel."

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: Email [email protected] and mention the book title in the subject of your message. If you have questions about any aspect of this book, please email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packtpub.com.