Leanpub Header

Skip to main content

Kotlin 实战深入

深入揭示 Kotlin 内部机制与基础原理的「如何」与「为什么」。

本书将带你从“如何使用 Kotlin”迈向“Kotlin 真正是如何运作的”,深入揭示语言的内部实现,解析生成的字节码与编译器行为,以及塑造 Kotlin 的核心内部机制。如果你希望在语言基础、协程和多平台开发中编写更聪明、更自信的 Kotlin 代码,这本书将告诉你一切为何如此设计。

Hardcover | Paperback | ISBN: 979-8243872744 

This book is a translation into Chinese (Simplified) of Practical Kotlin Deep Dive which was originally written in English

Minimum price

$42.99

$52.99

You pay

$52.99

Author earns

$42.39
$

...Or Buy With Credits!

You can get credits with a paid monthly or annual Reader Membership, or you can buy them here.

Buying multiple copies for your team? See below for a discount!

PDF
EPUB
WEB
438
Pages
35,351Words
About

About

About the Book

Kotlin 实战深入《Practical Kotlin Deep Dive》从 Kotlin 核心语言基础与内部机制出发,深入剖析 Kotlin 背后的「如何」与「为什么」,并延伸至其 API 的设计理念。本书涵盖 Kotlin 基础、标准库、协程、kotlinx 系列库、编译器内部实现以及 Kotlin Multiplatform。

本书不止停留在表层 API 的使用,而是深入 Kotlin 内部:通过真实的 Kotlin 函数实现,解析生成的字节码,讲解 Kotlin 编译器如何理解和处理这门语言。同时,本书直接引用 KEEP 提案、JetBrains YouTrack 讨论以及编译器源码,将概念与其起源和设计动机紧密结合,帮助你学会「理解 Kotlin」,而不仅仅是记住 API。

通过循序渐进的内容编排,本书确保你不仅知道如何高效地使用 Kotlin,还能理解语言为何如此设计,从而将这些洞见直接转化为更高质量的代码。

为了支持持续成长,本书提供了精心整理的参考资料和延伸阅读,帮助你在书本之外继续深入探索。对于复杂或不常见的术语,书中配有通俗易懂的脚注说明,使高级内容对初学者也同样友好,同时为资深开发者带来新的启发。

“Pro Tips for Mastery” 章节深入挖掘 Kotlin 函数的内部结构、算法、Kotlin 编译器的行为,以及在真实项目中至关重要的实现细节。资深工程师可以从中发现值得深思的细节,进一步打磨专业能力;而中级开发者则能借此提升 Kotlin 水平,建立更扎实的分析思维。

无论你是在优化性能关键代码、处理复杂的协程任务,还是探索多平台开发,本书都会引导你超越教程式学习,深入理解语言设计与内部机制,以更清晰的认知、更强的好奇心和更充分的信心来进行 Kotlin 开发。

Jaewoong Eum (skydoves)

This book is a translation into Chinese (Simplified) of Practical Kotlin Deep Dive which was originally written in English

Team Discounts

Team Discounts

Get a team discount on this book!

  • Up to 3 members

    Minimum price
    $107.00
    Suggested price
    $132.00
  • Up to 5 members

    Minimum price
    $171.00
    Suggested price
    $211.00
  • Up to 10 members

    Minimum price
    $300.00
    Suggested price
    $370.00
  • Up to 15 members

    Minimum price
    $429.00
    Suggested price
    $529.00
  • Up to 25 members

    Minimum price
    $644.00
    Suggested price
    $794.00

Author

About the Author

Jaewoong

The author of this book, Jaewoong Eum (known as skydoves), is a Google Developer Expert (GDE) for Android, Kotlin, and Firebase, an open-source developer created over 80+ open-source libraries and projects, collectively amassing 15+ million downloads annually. The author of Manifest Android Interview book and also the founder of Dove Letter—a subscription-based repository dedicated to sharing, learning, and discussing Android and Kotlin development.

Contents

Table of Contents

序言

推荐语

关于本书

  1. 本书适合谁
  2. 本书涵盖内容
  3. 如何使用本书
  4. 保持更新
  5. 问题反馈

赞助商

  1. CodeRabbit

第0章 Kotlin 语言

  1. 问题 0. 请解释 Kotlin 中的空安全机制
  2. 问题 1. Any、Unit 和 Nothing 类型的主要作用是什么?
  3. 问题 2. 什么是数据类,它与普通类有什么区别?
  4. 问题 3. 什么是密封类,请解释其使用场景
  5. 问题 4. 什么是内部类,它与嵌套类有什么区别?
  6. 问题 5. 何时使用枚举类?
  7. 问题 6. 什么是值类?
  8. 问题 7. 什么是对象,它与普通类有什么区别?
  9. 问题 8. 什么是伴生对象?
  10. 问题 9. var 和 val 有什么区别?
  11. 问题 10. 幕后字段和幕后属性有什么区别?
  12. 问题 11. 什么是委托属性?
  13. 问题 12. lazy 委托和 lateinit 有什么区别?
  14. 问题 13. 有哪些可见性修饰符?
  15. 问题 14. init 代码块何时被调用,它有什么主要特征?
  16. 问题 15. 什么是高阶函数,你可以从中获得什么优势?
  17. 问题 16. inline 关键字有哪些优点和限制?
  18. 问题 17. reified 关键字是什么,使用它有什么好处?
  19. 问题 18. 如何使用 Lambda 表达式?
  20. 问题 19. 什么是函数式(SAM)接口?
  21. 问题 20. 什么是扩展,它有哪些优缺点?
  22. 问题 21. 什么是结构相等性和引用相等性,它们有什么区别?
  23. 问题 22. 执行 null + null 操作会发生什么?
  24. 问题 23. 什么是 DSL,如何使用它?

第一章 Kotlin 标准库

  1. 问题 24:Kotlin 中有哪些集合类型?
  2. 问题 25:集合有哪些类型的转换操作符?
  3. 问题 26:解释迭代器的机制
  4. 问题 27:什么是 Sequence 及其机制?
  5. 问题 28:有哪些扩展函数可用于检索集合的部分内容?
  6. 问题 29:如何定义对象的排序?
  7. 问题 30:什么是作用域函数?

第二章 协程(Coroutines)

  1. 问题 31:什么是协程?
  2. 问题 32:什么是续体(Continuation),它与挂起函数内部有什么关系?
  3. 问题 33:协程和线程有什么区别?
  4. 问题 34:什么是协程构建器?
  5. 问题 35:什么是 Job?如何使用 SupervisorJob?
  6. 问题 36:什么是结构化并发(Structured Concurrency)?
  7. 问题 37:什么是 CoroutineScope,它与 CoroutineContext 有什么关系?
  8. 问题 38:什么是 Dispatchers?
  9. 问题 39:什么是 Channels?
  10. 问题 40:join() 和 await() 有什么区别?
  11. 问题 41:yield() 函数的作用是什么?
  12. 问题 41:如何在 Kotlin Coroutines 中处理异常?
  13. 问题 42:冷流(Cold Flow)和热流(Hot Flow)有什么区别?
  14. 问题 43:解释 StateFlow 和 SharedFlow 的区别
  15. 问题 44:Flow.flowOn() 操作符有什么作用?
  16. 问题 45:Flow.buffer() 操作符如何工作?
  17. 问题 46:Kotlin 的内部机制如何用 FusibleFlow 和 ChannelFlow 优化 Flow
  18. 问题 47:launchIn(Scope) 和 Scope.launch() 有什么区别?
  19. 问题 48:什么是 Flow 转换操作符:flatMapLatest、flatMapMerge、flatMapConcat?
  20. 问题 49:什么是 callbackFlow 和 channelFlow,以及它们的内部机制?

第三章 KotlinX 库

  1. 问题 50. 什么是 kotlinx-serialization,它是如何工作的?
  2. 问题 51. 什么是 kotlinx-datetime,为什么要用它而不是 Java 时间 API?
  3. 问题 52. 什么是 kotlinx-collections-immutable,何时应该使用它?
  4. 问题 53. 还有哪些值得注意的 KotlinX 库?

第四章 Kotlin 编译器和插件

  1. 问题 54. 什么是注解处理器、KAPT 和 KSP?
  2. 问题 55. Kotlin 编译器的结构是什么?
  3. 问题 56. 什么是 K2 编译器?
  4. 问题 57. 什么是 FIR(前端中间表示)?
  5. 问题 58. 什么是 IR,Kotlin 后端如何工作?
  6. 问题 59. 如何编写 Kotlin 编译器插件?
  7. 问题 60. 有哪些真实的 Kotlin 编译器插件示例和用例?

第五章:Kotlin 多平台

  1. 问题 61. 什么是 Kotlin 多平台?
  2. 问题 62. Kotlin 多平台如何处理平台特定的 API 并共享公共代码?
  3. 问题 63. Kotlin 多平台中有哪些并发或异步编程策略?
  4. 问题 64. Kotlin 多平台中有哪些 HTTP 网络通信策略?
  5. 问题 65. 什么是 Compose Multiplatform?
  6. 问题 66. Kotlin 多平台项目中源集是如何组织的?
  7. 问题 67. Kotlin/Native 如何处理内存管理和平台互操作性?
  8. 问题 68. Kotlin 多平台中有哪些测试策略?
  9. 问题 69. Kotlin 多平台中有哪些依赖注入策略?

结语

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub