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

Kotlin native in 10 min

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →
mbonnin
October 02, 2020

Kotlin native in 10 min

Everything Kotlin native in 10min

mbonnin

October 02, 2020

Transcript

16 slides
  1. • Created in 2011 by Jetbrains • Type inference, nullability,

    extension functions, lambdas, etc... 1. What is Kotlin ?
  2. 2. Swift ~ Kotlin class FrenchKit { func hello(name: String?)

    -> String { guard let name_ = name else { return "Hello unknown person" } return "Hello \(name_)" } } class Frenchkit { fun hello(name: String?): String { if (name != null) { return "Hello $name" } else { return "Hello unknown person" } } }
  3. 3. Compiling to native code Kotlin Compiler FrenchKit.kt LLVM IR

    LLVM Machine code Kotlin Tooling hello.framework frenchkit.class
  4. 4. Hello.h __attribute__((objc_subclassing_restricted)) __attribute__((swift_name("FrenchKit"))) @interface HelloFrenchKit : HelloBase - (instancetype)init

    __attribute__((swift_name("init()"))) __attribute__((objc_designated_initializer)); + (instancetype)new __attribute__((availability(swift, unavailable, message="use object initializers instead"))); - (NSString *)helloName:(NSString * _Nullable)name __attribute__((swift_name("hello(name:)"))); @end;
  5. 5. Swift interop Kotlin Swift class class interface protocol String

    String List Array Map Dictionary Function type Function type ∅ Struct Sealed classes, inline classes ∅ https://kotlinlang.org/docs/reference/native/objc_interop.html
  6. • JVM: GC • Objective-C: ARC • K/N: Reference Counting

    + Cycle detector • Variables must be frozen when accessed from multiple threads … • This is all going to change... 10. The memory model Elephant by Josh McGinn
  7. • Ecosystem ◦ SQL Delight ◦ Ktor ◦ Blue-Falcon ◦

    Koin • Samples ◦ joreilly/PeopleInSpace ◦ JetBrains/kotlinconf-app ◦ HearthSim/HSTracker Conclusion
  8. • Memory model ◦ Jetbrains Memory Management Roadmap ◦ Kotlin

    native concurrency explained ◦ Why the K/N memory model cannot hold Resources
  9. Resources • A journey to Kotlin Multiplatform • http://nilhcem.com/swift-is-like-kotlin/ •

    https://kotlinlang.org/docs/reference/native/objc _interop.html • https://kotlinlang.org/docs/reference/native-ove rview.html • https://arnestockmans.be/blog/build-run-jetpac k-compose-for-desktop

More Decks by mbonnin

Other Decks in Programming