Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The State of Kotlin | FOSDEM 2023

The State of Kotlin | FOSDEM 2023

Kotlin ecosystem is rapidly evolving over the years and 2022 was not an exception. Let's gather to recap everything that happened with Kotlin in the past year and to have a closer look at the language roadmap: from the new K2 compiler, to stable Kotlin Multiplatform and beyond.

Talk did together with Sergei Rybalkin

Marco Gomiero

February 04, 2023
Tweet

More Decks by Marco Gomiero

Other Decks in Programming

Transcript

  1. THE STATE OF KOTLIN
    Marco Gomiero @marcoGomier


    Sergei Rybalkin @lightdelay


    View Slide

  2. DISCLAIMER
    2

    View Slide

  3. CONF TALKS IN 2023 ARE SUPER EASY
    3

    View Slide

  4. HIGH LEVEL
    4
    https://www.jetbrains.com/lp/devecosystem-2022/kotlin/

    View Slide

  5. KOTLIN 2022 & 2023 IN 5 LETTERS
    5
    K2 KMP

    View Slide

  6. K2. SOLVING MAJOR INFRA PROBLEMS
    6
    ✦ IDE Stability & performance


    ✦ Build Speed


    ✦ Build Setup

    View Slide

  7. K2. SOLVING MAJOR INFRA PROBLEMS
    7

    View Slide

  8. K2. DEPRIORITISED
    8

    View Slide

  9. K2
    9
    ✦ K2 is in alpha with a promising impact on builds


    https://kotlinlang.org/docs/whatsnew17.html#new-kotlin-k2-compiler-for-the-jvm-in-alpha

    View Slide

  10. K2. FOR IMPATIENT
    10
    ✦ 1.6.21 to 1.7.x upgrade brings build improvements


    https://youtrack.jetbrains.com/issue/KT-48233/Switching-to-JVM-IR-backend-increases-compilation-time-by-more-than-15?
    _ga=2.68902353.1999403185.1669283102-592211788.1665648011&_gl=1*1fxko5p*_ga*NTkyMjExNzg4LjE2NjU2NDgwMTE.*_ga_9J976DJZ68*MTY2OTI4MzEwMi4zLjEuMTY2OTI4MzE4NS4wLjAuMA..#focus=Comments-27-6114542.0-0

    View Slide

  11. K2. BETA PLANS
    11
    ✦ Should be a fully-functional compiler


    ✦ Plans


    • Support the Multiplatform, Native, and JS backends.


    • Support Compose, kapt, KSP, Serializable, and other
    necessary plugins.
    https://youtrack.jetbrains.com/issue/KT-52604?_ga=2.93711642.642620354.1675451237-592211788.1665648011&_gl=1*df7plt*_ga*NTkyMjExNzg4LjE2NjU2NDgwMTE.*_ga_9J976DJZ68*MTY3NTQ1MTIzNy43LjAuMTY3NTQ1MTIzNy4wLjAuMA..

    View Slide

  12. K2. PLUGINS
    12
    ✦ kotlinx-serialization


    ✦ allopen, noarg


    ✦ lombok


    ✦ no support in KAPT


    ✦ no support in KSP

    View Slide

  13. K2. KAPT SUPPORT
    13

    View Slide

  14. K2. KAPT SUPPORT
    14
    🧐

    View Slide

  15. INTERESTING, WHAT THIS 2.0 MEAN
    15
    🧐

    View Slide

  16. K2. KOTLIN SYMBOL PROCESSING
    16

    View Slide

  17. K2. TESTING INFRA
    17

    View Slide

  18. K2 IDE
    18
    ✦ Performance


    ✦ Stability


    • K2 interaction with Analysis API


    ✦ Fewer features. A “Lightweight” release, as not all IDE
    features are implemented

    View Slide

  19. K2 IDE
    19
    ✦ Full code highlighting


    ✦ Basic code completion


    ✦ Debugger


    ✦ Basic Refactoring and Diagnostics


    ✦ Code formatter


    ✦ Run con
    fi
    gurations + gutters


    ✦ Gradle.kts support


    ✦ Kotlin Multiplatform support in all of the above features

    View Slide

  20. KOTLIN MULTIPLATFORM

    View Slide

  21. HIERARCHICAL PROJECT STRUCTURE
    ✦ Now enabled by default


    ✦ Share code between several similar targets:

    e.g. iosArm64 and iosX64
    21
    https://kotlinlang.org/docs/whatsnew1620.html#hierarchical-structure-support-for-multiplatform-projects
    1.6.20

    View Slide

  22. KOTLIN/NATIVE PERFORMANCE IMPROVEMENTS
    ✦ 15% reduction in execution time


    ✦ 20% reduction in the code size of both release and debug
    binaries


    ✦ 26% reduction in the compilation time of release binaries
    22
    1.6.20
    https://kotlinlang.org/docs/whatsnew1620.html#performance-improvements

    View Slide

  23. NEW KOTLIN/NATIVE MEMORY MANAGER
    ✦ Now enabled by default


    ✦ From deferred reference-counting GC to tracing GC


    ✦ No restrictions on object sharing between threads


    ✦ Fully leak-free concurrent programming primitives


    ✦ No more freezing 🥶
    23
    https://kotlinlang.org/docs/whatsnew1720.html#the-new-kotlin-native-memory-manager-enabled-by-default
    https://blog.jetbrains.com/kotlin/2021/05/kotlin-native-memory-management-update/
    https://kotlinlang.org/docs/native-memory-manager.html
    1.7.20

    View Slide

  24. KOTLIN MULTIPLATFORM MOBILE PROMOTED TO BETA
    24
    1.7.20

    🎉


    ✦ The technology is almost done and is safe to use in your
    projects


    ✦ Some more work on the toolchain is required


    ✦ Start using and learning KMM, it’s fun!
    https://blog.jetbrains.com/kotlin/2022/10/kmm-beta/

    View Slide

  25. IMPROVED OBJECTIVE-C/SWIFT INTEROPERABILITY
    25
    https://kotlinlang.org/docs/whatsnew18.html#improved-objective-c-swift-interoperability
    @ObjCName

    Specify a more idiomatic name in Swift or Objective-C, instead
    of renaming the Kotlin declaration.


    1.8.0

    View Slide

  26. IMPROVED OBJECTIVE-C/SWIFT INTEROPERABILITY
    26
    https://kotlinlang.org/docs/whatsnew18.html#improved-objective-c-swift-interoperability
    @HiddenFromObjC


    The Kotlin compiler will not export a function or property to
    Objective-C and, consequently, Swift.
    1.8.0

    View Slide

  27. IMPROVED OBJECTIVE-C/SWIFT INTEROPERABILITY
    27
    https://kotlinlang.org/docs/whatsnew18.html#improved-objective-c-swift-interoperability
    1.8.0
    @ShouldRefineInSwift


    The Kotlin compiler will mark a function or property as
    swift_private in the generated Objective-C API.

    Such declarations get the __ pre
    fi
    x, which makes them
    “invisible” to Swift code.

    View Slide

  28. NEW ANDROID SOURCE SET LAYOUT
    28
    1.8.0
    ✦ No more androidTest and androidAndroidTest 😅


    ✦ Say hello to androidUnitTest and androidInstrumentedTest
    https://kotlinlang.org/docs/whatsnew18.html#kotlin-multiplatform-a-new-android-source-set-layout

    View Slide

  29. NEW ANDROID SOURCE SET LAYOUT
    29
    1.8.0
    ✦ More clarity on the Manifest location
    https://kotlinlang.org/docs/whatsnew18.html#kotlin-multiplatform-a-new-android-source-set-layout

    View Slide

  30. NEW ANDROID SOURCE SET LAYOUT
    30
    1.8.0
    ✦ Enable the new layout with a Gradle Option


    kotlin.mpp.androidSourceSetLayoutVersion=2
    https://kotlinlang.org/docs/whatsnew18.html#kotlin-multiplatform-a-new-android-source-set-layout

    View Slide

  31. STABLE KOTLIN/JS IR COMPILER BACKEND
    31
    1.8.0
    ✦ Kotlin/JS IR compiler backend is now Stable


    ✦ Incremental compilation enabled by default


    ✦ All the three backends now works with the same IR for Kotlin
    code
    https://kotlinlang.org/docs/whatsnew18.html#stable-js-ir-compiler-backend

    View Slide

  32. KOTLIN/NATIVE: BINARY COMPATIBILITY BETWEEN INCREMENTAL RELEASES
    32
    https://youtrack.jetbrains.com/issue/KT-42293
    ✦ Releases from 1.4.0 to 1.8.0 are experimentally binary
    backward compatible.


    ✦ Processes have been set up to keep binary backward
    compatibility between releases

    View Slide

  33. COMPOSE MULTIPLATFORM
    33
    https://www.jetbrains.com/lp/compose-mpp/

    View Slide

  34. COMPOSE MULTIPLATFORM: 1.3.0
    34
    https://github.com/JetBrains/compose-jb/releases/tag/v1.3.0

    View Slide

  35. COMPOSE FOR IOS 🤯
    35
    https://github.com/JetBrains/compose-jb/tree/master/experimental/examples/falling-balls-mpp

    View Slide

  36. COMPOSE FOR IOS 🤯
    36
    https://github.com/touchlab/DroidconKotlin

    View Slide

  37. IN THIS YEAR ROADMAP 🔮
    37
    https://kotlinlang.org/docs/roadmap.html
    ✦ Improve the new Kotlin/Native memory manager robustness
    and performance and deprecate the old one


    ✦ Improve Kotlin/Native compilation time


    ✦ Improve exporting Kotlin code to Objective-C


    ✦ Stabilise klib: keep binary compatibility easier for library
    authors

    View Slide

  38. ✦ Promote Kotlin Multiplatform Mobile to Stable
    IN THIS YEAR ROADMAP 🔮
    38
    https://kotlinlang.org/docs/roadmap.html
    • Remove old and outdated pieces of the Multiplatform toolchain (non-hierarchical project support, old
    Gradle plugins, etc.).


    • Finalize the switch to the new Kotlin/Native memory model.


    • Provide clear compatibility guarantees for all pieces of the Multiplatform toolchain and support them
    with thorough testing and tight time-to-respond for any issues that might arise.


    • Improve Android support in Multiplatform projects.


    • Prototype the support for Kotlin Multiplatform in K2.


    • Stabilize the Multiplatform toolchain based on our adopters’ use cases.


    • Improve our build tool’s usability, including special support for the Android target in multiplatform
    projects.


    • Improve Kotlin/Native’s interoperability with the iOS world.


    • Make our onboarding more user-friendly and our documentation more comprehensive.

    View Slide

  39. THANK YOU
    Sergei Rybalkin


    @lightdelay
    Marco Gomiero


    @marcoGomier


    androiddev.social/@marcogom

    View Slide