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

K/N for mobile developers (including libraries' snippets)

Enrique López Mañas
October 21, 2019

K/N for mobile developers (including libraries' snippets)

Enrique López Mañas

October 21, 2019


  1. Ego Slide • Freelance Dev • Google Developer Expert •

    KotlinWeekly publisher • @eenriquelopez • Mainly Android Kotlin, Backend Kotlin, iOS (mostly Swift)
  2. Kotlin/Native - Uses LLVM (5.0) - Provides runtime guarantees -

    Exceptions, memory management - Interop with C/Objective-C (Swift) - Platform libraries (POSIX, Apple Frameworks, Win32, DOM, etc)
  3. The compiler -Shares Front-end with Kotlin/JVM and Kotlin/JS - Written

    in Java and Kotlin - Produces bitcode via LLVM API
  4. Memory Management - ARC with Cycle Collector - When working

    pure Kotlin,don’t worry about memory management - Weak references supported - Memory sharing model - Different threads have disjoint object graphs - Object subgraphs can be transferred between threads - Immutable objects can be shared
  5. Interoperatibility - Interoperatibility with C, Objective-C and Swift - Kotlin

    can call C/Objective-C and vice-versa - Kotlin can extend Objective-C classes and vice-versa - Memory management aware of Objective-C runtime
  6. Mapping - Numbers are kept - Strings converted - Kotlin

    declarations wrapping C entities (functions, struct, unions, etc.) are auto- generated - Objective-C OO concepts (classes, protocols, blocks) are represented as matching Kotlin entities (classes, interfaces, lambdas) - For Objective-C, Kotlin code can be compiled to a framework
  7. Kotlin Library - Hold collection of code for reusability and

    sharing - Own format: ‘klib’ extension, which holds metadata and bitcode - Tool for creating and storing libraries in repositories
  8. ktor - Web application framework -Domain Specific Language (DSL) syntax

    for web apps-Kotlin coroutines for asynchronous programming -Can be used on web, iOS and Android -Provides a unified toolset with a single language, like Node.js but with type-safety and build-concurrency.
  9. The future Hard to make predictions, easier to bet safe

    “I don’t know what will happen in 10 years, but there will be people asking in SO about regular expressions, and there will be another JS framework ”
  10. Flutter vs Kotlin/Native? Flutter - custom UI Widgets Kotlin -

    more performant Kotlin - better ecosystem
  11. Recommendations - Use it with caution - Shared components -

    Keep versioning in mind - Do not compromise 100% of a project
  12. Further resources Kotlin Slack (kotlinlang.slack.com) Touchlab resources (https://github.com/touchlab) Kotlin Weekly

    (http://kotlinweekly.net) K/N documentation (https://kotlinlang.org/docs/ reference/native-overview.html)