Achieving Structured Concurrency with Coroutines
Pierre-Olivier Laurence and Amanda Hinchman-Dominguez, with G. Blake Meike and Mike Dunn

#Android
#Kotlin
#Concurrency
#Java
#Framework
🌟 توسعهی اپهای اندروید همیشه یه چالش جدی بهنظر میرسه، مخصوصاً وقتی پای یه زبان جدید وسطه: Kotlin، زبان رسمی توسعهی اندروید. این کتاب عملی بهت یاد میده چطور از Java به Kotlin مهاجرت کنی و مزیت واقعی این زبان رو در کنترل همزمانی (asynchronous computations) درک کنی.
چهار نویسندهی کتاب — پیر-اولیویه لورانس، آماندا هیچمن-دومینگز، جی. بلیک مایک، و مایک دان — نحوهی پیادهسازی کارهای رایج در توسعهی بومی اندروید رو بررسی میکنن و نشون میدن Kotlin چطور در حل مشکلات همزمانی و Performance نقش محوری داره. تمرکز اصلی کتاب روی مفهوم Structured Concurrency با استفاده از Coroutines ـه، یکی از قدرتمندترین ویژگیهای Kotlin.
📚 آنچه یاد میگیری:
💡 مفاهیم پایهای Kotlin و فریمورک کالکشنهاش
🔧 اصول اندروید: سیستمعامل، Application Container و کامپوننتها
🧵 ایمنی در برابر Thread ها و مدیریت Concurrency
⏱ نوشتن کدهای async با هزینهی پایین و رفتار sequential
⚙️ درک کامل Structured Concurrency با Coroutines
📡 نحوهی کارکرد Channels و ارتباط بین Coroutineها
💫 استفاده از Flowها برای پردازش دادهی asynchronous
📈 نکات Performance و استفاده از Android Profiler
💡 بهینهسازی مصرف منابع اپلیکیشن
🧩 فهرست فصلها
📖 از پیشگفتار کتاب:
💬 شرکت JetBrains، خالق Kotlin، تصمیم گرفت زبانی بسازه که جاهای خالی جاوا در توسعهی اندروید رو پر کنه و اندروید رو از دنبالکنندهی ترندها، به سازندهی ترندها تبدیل کنه.
نسخهی 1.0 زبان Kotlin در فوریه ۲۰۱۵ منتشر شد. زبانی مختصر، ایمن، عملگرا و کاملاً سازگار با Java است؛ قابل استفاده در سمت سرور، اپهای اندروید، دسکتاپ، دستگاههای IoT و بسیاری کاربردهای دیگه.
امروز بیش از ۶۰٪ توسعهدهندگان حرفهای اندروید از Kotlin استفاده میکنن — نتیجهی تصمیم گوگل برای انتخاب Kotlin بهعنوان زبان رسمی توسعهی اندروید.
👥 مخاطبان کتاب:
هر کدوم از ۶ میلیون مهندس اندروید روی کره زمین میتونن از این کتاب بهره ببرن.
🎯 هدف اصلی، توسعهدهندههایی هستن که هنوز از Java به Kotlin مهاجرت نکردن یا فقط یه آشنایی سطحی دارند.
🔹 سناریوی ۱: مهندس جاوا که تازه داره Kotlin رو امتحان میکنه و میفهمه این فقط یه Syntax جدید نیست، بلکه یه طرز فکر جدیده—از برنامهنویسی تابعی تا coroutines.
🔹 سناریوی ۲: تیمی از توسعهدهندگان جاوا که بین استفاده از دو زبان تردید دارن و دنبال شواهد قانعکنندهان.
🔹 سناریوی ۳: توسعهدهندهی اندروید باتجربه که گاهی با Kotlin کار کرده، ولی هنوز در اصل با Java راحتتره—کتاب کمکش میکنه Kotlin رو با عمق واقعی درک کنه و ازش با اطمینان استفاده کنه.
🧠 هدف نگارش کتاب:
کتابهای زیادی دربارهی Android، Kotlin یا Concurrency وجود دارن، اما این اثر یه تقاطع تخصصی و منحصربهفرد بین هر سه زمینهست. Kotlin به اندروید فقط خوانایی بهتر نمیده، بلکه راههای تازهای برای حل مشکلات همزمانی ارائه میکنه. این کتاب مثل یه نقطهی ثبت تاریخیه، نشوندهندهی مسیر رشد اندروید تا امروز و آیندهی اون با Kotlin.
این کتاب یه جور README بزرگ برای دولوپرهای اندرویده — از مهاجرت از Java تا درک عمیق coroutines و Flowها، باندس واقعی به سبک یک مهندس واقعی
👨💻 دربارهی نویسندگان:
🧠 مایک دان (Mike Dunn)
مدیر مهندسی موبایل در O’Reilly Media، از جمله اعضای فعال جامعهی AOSP و توسعهدهندهی کتابخانهی محبوب TileView. مشارکت در ExoPlayer و کتابخانهی Google Closure. برنامهنویس حرفهای با بیش از ۱۵ سال تجربه و دانشجوی کارشناسیارشد علوم کامپیوتر در Georgia Tech.
⚙️ بلِیک مایک (Blake Meike)
مهندس ارشد نرمافزار در Amazon، با بیش از ۱۰ سال تجربهی توسعه با Java و کار روی انواع پلتفرمهای موبایل.
✨ آماندا هیچمن دومینگز (Amanda Hinchman-Dominguez)
کارشناس رسمی Kotlin GDE، مهندس اندروید در Groupon، سخنران جهانی و فعال جامعه Kotlin. شرکتکنندهی کنفرانسهای KotlinConf, Chicago Roboto, و فعال در پروژههای متنباز مثل Arrow Meta و TornadoFX.
🧩 پیر-اولیویه لورانس (Pierre-Olivier Laurence)
رهبر تیم مهندسی نرمافزار در Safran Aircraft Engines (پاریس)، توسعهدهندهی تماموقت اندروید با بیش از یک دهه تجربه در Java و Linux. از اولین پذیرندگان Kotlin، سازندهی نسخهی ۱۰۰٪ Kotlin از کتابخانهی TileView با استفاده از coroutines برای دستیابی به عملکرد بالا.
Developing applications for the Android mobile operating system can seem daunting, particularly if it requires learning a new programming language: Kotlin, now Androidâ??s officialdevelopment language. With this practical book, Android developers will learn how to make the transition from Java to Kotlin, including how Kotlin provides a true advantage for gaining control over asynchronous computations.
Authors Pierre-Olivier Laurence, Amanda Hinchman-Dominguez, G. Blake Meike, and Mike Dunn explore implementations of the most common tasks in native Android development, and show you how Kotlin can help you solve concurrency problems. With a focus on structured concurrency, a new asynchronous programming paradigm, this book will guide you through one of Kotlin's most powerful constructs, coroutines.
Table of Contents
Chapter 1. Kotlin Essentials
Chapter 2. The Kotlin Collections Framework
Chapter 3. Android Fundamentals
Chapter 4. Concurrency in Android
Chapter 5. Thread Safety
Chapter 6. Handling Concurrency Using Callbacks
Chapter 7. Coroutines Concepts
Chapter 8. Structured Concurrency with Coroutines
Chapter 9. Channels
Chapter 10. Flows
Chapter 11. Performance Considerations with Android Profiling Tools
Chapter 12. Trimming Down Resource Consumption with Performance Optimizations
JetBrains created Kotlin for two reasons: there was no language that filled all the gaps in Android development using (legacy) Java libraries, and a new language would allow Android development to set trends, rather than just follow them.
In February 2015, Kotlin 1.0 was officially announced. Kotlin is concise, safe, pragmatic, and focused on interoperability with Java code. It can be used everywhere Java is used today: for server-side development, Android apps, desktop or portable clients, IoT device programming, and much, much more. Kotlin gained popularity among Android developers quite rapidly, and Google’s decision to adopt Kotlin as the official language of Android development resulted in skyrocketing interest in the language. According to the Android Developers website, more than 60% of professional Android developers currently use Kotlin.
Who Should Read This Book
Any of the over six million Android engineers. We believe that virtually every Android engineer could benefit from this book. While a small percentage will be fluent in Kotlin, even they will likely learn something from the information we’ll present. But realistically, we’re targeting the very large majority who haven’t made the transition to Kotlin. This book is also for those who have dipped a toe in but not gained the same level of familiarity with Kotlin that they may have accrued in Java-centric Android development:
Scenario 1: A reader is proficient in Java, heard of this new Kotlin language, and wants to try it out. So they read some online tutorial and start using it and it works great. Soon they realize that this isn’t just a new syntax. The idioms aren’t the same (e.g., functional programming, coroutines) and a whole new way of developing is now possible. But they lack guidelines, structure. For them, this book is a perfect fit.
Scenario 2: A reader is part of a small team of Java developers. They have discussions about whether they should start including Kotlin in their project. Even if Kotlin is said to be 100% interoperable with Java, some colleagues argue that introducing another language will add complexity to the project. Others suggest it might limit the number of colleagues who will be able to work on the project because of the need to master two languages. The reader could use this book to convince their colleagues, if they can show that the benefits will outweigh the costs.
Scenario 3: An experienced Android developer may have played around with Kotlin or written a feature in it, but still falls back to the home base of Java when things need to get done. This was the scenario we found ourselves in when realizing the book we’re pitching now would have made our lives much easier. This is also the state we see most commonly around us—many Android devs have touched Kotlin, and many feel like they understand enough to write it when necessary, but they are either unaware, or simply unconvinced, of the significance of data classes, immutable properties, and structured concurrency. We think this book will turn a curious person into a committed evangelist.
Why We Wrote This Book
There are plenty of books that show how Android works, how Kotlin works, or how concurrency works. Kotlin is becoming wildly popular with Android development for its easy adoption and cleaner syntax, but Kotlin offers Android much more than that: it offers new ways to solve concurrency problems in Android. We wrote this book to provide a unique and specific intersectionality of these topics in great depth. Both Android and Kotlin are rapidly changing, separately and together. Trying to keep up with all the changes can be difficult. We view this book as a valuable checkpoint in history: showing where Android came from, where it is now, and how it will continue to evolve with Kotlin as the language matures.
Mike Dunn is the author of Native Mobile Development: an Android to iOS Cross Reference. He is currently the Principal Mobile Engineer at O’Reilly Media, a recognized member of the AOSP community, and a dedicated contributor to the Android open source ecosystem, including the popular tiling image library, TileView. He’s contributed to Google’s Closure library, and provided extensions for Google’s next-gen Android media player, ExoPlayer. Mike has been programming professionally for about 15 years, and is continuing to study computer science in the master's program at the Georgia Institute of Technology.
Blake Meike, Senior Software Development Engineer at Amazon, has more than 10 years of experience with Java. He’s developed applications using most of the GUI toolkits and several of the Java mobile device platforms.
Amanda Hinchman-Dominguez is a Kotlin Google Developer Expert, Android engineer at Groupon, and active in the global Kotlin community, both as a speaker and as a community organizer. Starting out in academia, she obtained a B.S. in Computer Science at Grinnell College. Working across web, mobile, and native-desktop development, her roots in metaprogramming research1 and community-based learning heavily influenced her direction in both her interests and her career. Kotlin community back in 2016 and eventually, her career. Her passion for Kotlin naturally shifted towards Android development some years in the industry.
She's given technical lectures in Kotlin internationally officially since 2017. She's written dozens more on topics ranging from metaprogramming, compilers and application development. She's participated in the TornadoFX community, and contributed to the Arrow-meta open-source project. She's also involved with the world community via conferences like KotlinConf, Chicago Roboto, Chicago Kotlin User Group, and more. Her current focus is capturing the ever-evolving history of Kotlin and Android and establishing a stronger presence of the Kotlin community.
Pierre-Olivier Laurence is the Lead Software Engineer at Safran Aircraft Engines near Paris, France. He started learning Java and Linux systems over a decade ago, which quickly lead to full time Android development. A frequent collaborator on the TileView open source library since its inception, Pierre recently created a version of the library that's 100% Kotlin, leveraging the power of Kotlin coroutines for truly impressive performance gains. An early adopter of Kotlin, Pierre has maintained several open source Kotlin projects since the language was introduced in 2015. With an eye toward personal development, Pierre is an avid reader of O'Reilly books and looks forward to mastering even more technologies in the future.









