Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds

Free eBook - Mastering Kotlin

2.7 (3 reviews total)
By Nate Ebel
  • A new free eBook every day on the latest in tech
  • 30 permanently free eBooks from our core tech library
  1. Section 1: Kotlin – A Modern Solution to Application Development
About this book
Using Kotlin without taking advantage of its power and interoperability is like owning a sports car and never taking it out of the garage. While documentation and introductory resources can help you learn the basics of Kotlin, the fact that it’s a new language means that there are limited learning resources and code bases available in comparison to Java and other established languages. This Kotlin book will show you how to leverage software designs and concepts that have made Java the most dominant enterprise programming language. You’ll understand how Kotlin is a modern approach to object-oriented programming (OOP). This book will take you through the vast array of features that Kotlin provides over other languages. These features include seamless interoperability with Java, efficient syntax, built-in functional programming constructs, and support for creating your own DSL. Finally, you will gain an understanding of implementing practical design patterns and best practices to help you master the Kotlin language. By the end of the book, you'll have obtained an advanced understanding of Kotlin in order to be able to build production-grade applications.
Publication date:
October 2019
Publisher
Packt
Pages
434
ISBN
9781838555726

 

A New Challenger Approaches

In this chapter, you'll gain an understanding of what Kotlin is, how it came about, and why it's quickly gaining popularity. You'll find a high-level overview of key language features, as well as the design principles behind the language itself. Finally, this chapter will lay the foundations for the following chapters' focus on features, patterns, platforms, and best practices for improving your understanding of the Kotlin programming language.

This chapter covers the following topics:

  • Creating a modern language for the Java Virtual Machine (JVM)
  • Moving beyond the JVM
  • Designing Kotlin with best practices in mind
  • Checking in on the current state of Kotlin
 

Technical requirements

In order to download, compile, and execute the samples found in this chapter, you must have the following:

  • IntelliJ IDEA 2018.3 Community or Ultimate editions, or newer
  • An internet connection
  • Git and GitHub (optional)

To download all of the code in this chapter, including the examples and code snippets, please refer to the following GitHub link: https://github.com/PacktPublishing/Mastering-Kotlin/tree/master/Chapter01.

 

Creating a modern language for the JVM

Kotlin was born out of a desire for a modern programming language that could be run on the JVM while still being fully compatible with Java and existing Java tooling. With these goals in mind, Kotlin has evolved into one of the fastest growing programming languages in the world and continues to carve out space for itself across multiple domains.

GitHub's 2018 State of the Octoverse report listed Kotlin as the fastest growing language on GitHub: https://github.blog/2018-11-15-state-of-the-octoverse-top-programming-languages/.

In this section, we're going to dive into what Kotlin is, how it came to be, and why it's great for developers.

What is Kotlin?

So, what exactly is...

 

Moving beyond the JVM

Kotlin may owe its origin to JVM interoperability, but it has quickly moved beyond pure JVM applications. One of the early wins for Kotlin was acceptance in the Android development community where most developers were required to use Java 6 or Java 7. Kotlin enabled Android developers to use language features, such as lambdas, which were not available on older versions of Java.

Outside of Android, Kotlin can now be transpiled to JavaScript, used in multiplatform mobile applications, or compiled to run natively on macOS, Windows, and Linux.

Kotlin for Android

To date, Kotlin has received the most popularity in the Android development community. Kotlin starting gaining traction for Android development in...

 

Designing Kotlin with best practices in mind

Kotlin has been designed based on decades of experience from working with Java and other programming languages. By building on this experience, JetBrains has worked to improve the developer experience with Kotlin by focusing on things such as first-class tooling support from day one, fast build times, and bringing modern features and best practices to the language design.

Learning from Java

Kotlin is 100% compatible with Java through the bytecode that allows both to target the JVM. Kotlin's origin stems from wanting modern language features and compile speeds that other JVM languages couldn't provide. Because of these, Kotlin is heavily influenced by Java, but can improve...

 

Checking in on the current state of Kotlin

Today, Kotlin is one of the fastest growing languages in the world. It has already proven itself for Android development and is now starting to find a home in other domains as well.

Developing Kotlin in the open

Since its public announcement, JetBrains has been very open with the development of Kotlin. This includes a public issue tracker, regular blog posts, conference talks, a yearly Kotlin census, and they even have their own conference now, KotlinConf.

You can submit your feedback, or leave your own issues and feature requests in the Kotlin issue tracker: https://youtrack.jetbrains.net/issues/KT.

Kotlin has seen four major stable releases to date, which are as follows:

  • v1.0:...
 

Summary

Kotlin is a modern programming language that can be used to build applications across mobile, the web, and native platforms. Since its inception, JetBrains has developed Kotlin to provide an excellent developer and integration experience so Kotlin can be learned gradually and slowly integrated into existing projects. The design and development of the language has been done very much in the open, and you can view the Kotlin issue tracker and submit your own ideas, issues, and feedback to help contribute to the language. Kotlin's popularity continues to increase rapidly, and its ability to target a variety of platforms makes it likely that the popularity trend will continue.

In this book, you'll learn firsthand why Kotlin is growing so rapidly. We'll start by exploring different application architectures, and how to model data and manage state using Kotlin...

 

Questions

  1. Which company started the development of the Kotlin programming language?
  2. When was Kotlin announced to the world?
  3. Who is the lead designer of Kotlin?
  4. What platforms did Kotlin initially target?
  5. Which platforms are currently supported by Kotlin?
  6. For which platform has Kotlin gained the most popularity?
  7. List two factors that have contributed to the rapid growth of Kotlin.
 

Further reading

About the Author
  • Nate Ebel

    Nate Ebel is a software developer who enjoys building great software and helping others do the same. He has worked with Android since its early days, across a variety of projects, from creative and educational apps, mapping and navigation applications, to the evolution of robotic controllers. Nate has a passion for technology, education, and software development, and enjoys opportunities to combine the three. He enjoys being involved in the Android developer community and is an active contributor through conference speaking, blogging, and event organizing. He is working to help himself and others dream, learn, and create in an effort to positively impact others.

    Browse publications by this author
Latest Reviews (3 reviews total)
Excellent book. Covered all aspects of Kotlin in a very easy to enjoyable approach. One of my favourite software development books.
This book is hopelessly out of date. Not one of the projects you can download works!
Book is very superficial, contains only simple examples and a lot of boilerplates like technical requirements for each chapter. I don't recommend this book.
Recommended For You
Full-Stack React, TypeScript, and Node

Discover the current landscape of full-stack development and how to leverage modern web technologies for building production-ready React.js applications to deploy on AWS

By David Choi
Machine Learning for Algorithmic Trading - Second Edition

Leverage machine learning to design and back-test automated trading strategies for real-world markets using pandas, TA-Lib, scikit-learn, LightGBM, SpaCy, Gensim, TensorFlow 2, Zipline, backtrader, Alphalens, and pyfolio.

By Stefan Jansen
Solutions Architect's Handbook

From fundamentals and design patterns to the different strategies for creating secure and reliable architectures in AWS cloud, learn everything you need to become a successful solutions architect

By Saurabh Shrivastava and 1 more
The Python Workshop

Learn the fundamentals of clean, effective Python coding and build the practical skills to tackle your own software development or data science projects

By Andrew Bird and 4 more