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


Enrique López Mañas
November 17, 2023


Enrique López Mañas

November 17, 2023


  1. Ego Slide • Google Developer Expert • 🇻🇳 🇩🇪 🇪🇸

    • Kotlin Weekly 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. expect/actual // Common expect fun randomUUID(): String // Android import

    java.util.* actual fun randomUUID() = UUID.randomUUID().toString() 
 // iOS import platform.Foundation.NSUUID actual fun randomUUID(): String = NSUUID().UUIDString()
  9. 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. 

  10. Considerations in state // Kotlin enum class LogLevel { ERROR,

    WARNING, INFO, DEBUG } class Logger { companion object default { fun log(level: LogLevel = LogLevel.ERROR, message: String, completion: (Boolean) -> Unit) { } } }
  11. 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 ”
  12. Recommendations - Use it with caution - Shared components -

    Keep versioning in mind - Do not compromise 100% of a project
  13. 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/ native-overview.html)