Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Learning Concurrency in Kotlin
  • Table Of Contents Toc
  • Feedback & Rating feedback
Learning Concurrency in Kotlin

Learning Concurrency in Kotlin

By : Castiblanco Torres
4 (6)
close
close
Learning Concurrency in Kotlin

Learning Concurrency in Kotlin

4 (6)
By: Castiblanco Torres

Overview of this book

Kotlin is a modern and statically typed programming language with support for concurrency. Complete with detailed explanations of essential concepts, practical examples and self-assessment questions, Learning Concurrency in Kotlin addresses the unique challenges in design and implementation of concurrent code. This practical guide will help you to build distributed and scalable applications using Kotlin. Beginning with an introduction to Kotlin's coroutines, you’ll learn how to write concurrent code and understand the fundamental concepts needed to write multithreaded software in Kotlin. You'll explore how to communicate between and synchronize your threads and coroutines to write collaborative asynchronous applications. You'll also learn how to handle errors and exceptions, as well as how to work with a multicore processor to run several programs in parallel. In addition to this, you’ll delve into how coroutines work with each other. Finally, you’ll be able to build an Android application such as an RSS reader by putting your knowledge into practice. By the end of this book, you’ll have learned techniques and skills to write optimized code and multithread applications.
Table of Contents (11 chapters)
close
close

Preface

The era when the speed of a single core in a processor would duplicate every few years is long over. Transistors have reached unbelievably small sizes, yet heating, power consumption, and other technical and practical challenges have made it difficult to keep increasing their speed in a user-friendly, affordable way. Even more so if you consider not only desktop computers but also mobile devices such as smartphones and tablets, which are universal nowadays. So, in recent years, the focus has been put on equipping these computing devices with more than one core or more than one processor – running with a balanced configuration of speed, heating, and power consumption.

The challenge becomes using those cores efficiently and effectively. An increase in the speed of a core will directly improve the execution time of the software running on it – for CPU-bound operations – but that is not the case when another core or processor is added. For an application to be able to take advantage of multiple cores, it needs to be written with that objective in mind. It needs to be concurrent.

However, concurrency not only benefits applications that will run in multiple cores. A concurrent application will usually work faster than a single-threaded application for IO-bound operations, even if running in a single core, because it allows the application to use the processor while other tasks are waiting for IO devices. For example, while waiting for a network operation.

So it's in your hands, as the developer, the person reading this book, to write the software that will work efficiently both in a single-core device and in a multi-core one. It's in my hands, the writer, to provide you with enough information, expressed in an understandable way, to achieve this goal. With this in mind, I have written this book, expecting nothing but basic Kotlin knowledge from you. I have tried to distill everything, from the very concepts of concurrency to the very specifics of how coroutines are compiled, for you. I have done it so that we both can do our part in bringing our users – be it humans or other systems a fast yet reliable experience.

This book covers various topics in great detail, using tools such as diagrams, examples, and more often than not, real-life use cases. For that reason, most of the chapters follow the creation and modification of an RSS reader for Android, completely written in Kotlin and using only the tools and primitives provided by the language and the coroutines library. I encourage you to follow along the creation of the application and to type the code instead of copying it – especially if you have only the printed version of the book so that you get to interiorize how to do it. I encourage you even more to go off-script and try some things for yourself; if you start wondering whether something can be accomplished in a certain way, it means that your brain is beginning to get a grasp of how to apply the concepts. And there's nothing better than trying something to know if it works.

One thing that you should be aware of is that while coroutines are being developed for all the platforms that Kotlin supports JVM, JavaScript, and Kotlin/Native at the time of writing this book, the most complete implementation is that of JVM. For that reason, I have written this book centered around what is available and how things work for the JVM. However, know that many of the concepts and primitives work in a similar fashion for JavaScript, and I believe they will work the same way in Kotlin/Native once implemented.

There are still many topics that I wasn't able to write about, but I do believe that the contents of this book are enough to get you to a point from where you can confidently move forward on you own, and I also believe that you will be able to write many of your concurrent applications based on what will be covered in these pages.

This puts the future squarely in the hands of those who know computers not for what they are, but the potential of what they can be
- Gordon
Computers aren't the thing, they are the thing that gets us to the thing
- Joe
Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Learning Concurrency in Kotlin
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon