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

Pragmatic Code Sharing with Kotlin Multiplatfor...

Pragmatic Code Sharing with Kotlin Multiplatform (Simonyi 2024)

Márton Braun

March 17, 2024
Tweet

More Decks by Márton Braun

Other Decks in Programming

Transcript

  1. Kotlin 1.0 Nyilvános bejelentés Projekt kezdete Open source Native JavaScript

    Kotlin/JVM .kt .class Kotlin/Native .kt .klib|.kexe Kotlin/JS .kt .js
  2. Kotlin 1.0 Nyilvános bejelentés Projekt kezdete Open source Native JavaScript

    KMP stable Wasm Kotlin/JVM .kt .class Kotlin/Native .kt .klib|.kexe Kotlin/JS .kt .js Kotlin/Wasm .kt .wasm
  3. Jetpack KMP Kotlin first Java + Kotlin Kotlin 1.0 Nyilvános

    bejelentés Projekt kezdete Open source Native JavaScript KMP stable Wasm
  4. .kt .kt .kt Android Desktop iOS Common class Person(val name:

    String, var age: Int) fun greet(person: Person) { println("Hello, ${person.name}") }
  5. .kt .kt .kt Android Desktop iOS Common fun List<Person>.duplicates(): Map<String,

    Int> { return map { it.name.substringBefore(" ") } .groupingBy { it } .eachCount() .filter { (name, count) -> count > 1 } }
  6. Android Desktop iOS Common fun getPlatform(): String fun getPlatform(): String

    = "Java ${System.getProperty("java.version")}" expect actual actual actual
  7. Android Desktop iOS Common fun getPlatform(): String fun getPlatform(): String

    = "Java ${System.getProperty("java.version")}" fun getPlatform(): String = "Android ${Build.VERSION.SDK_INT}" expect actual actual actual
  8. Android Desktop iOS Common fun getPlatform(): String fun getPlatform(): String

    = "Java ${System.getProperty("java.version")}" fun getPlatform(): String = "iOS ${UIDevice.currentDevice.systemVersion}" fun getPlatform(): String = "Android ${Build.VERSION.SDK_INT}" expect actual actual actual
  9. .kt .kt .kt Android Desktop iOS Common import io.ktor.client.* suspend

    fun loadHtml(): String { val client = HttpClient() val response = client.get("https://kotlinlang.org") return response.body<String>() }
  10. Desktop logic Android logic iOS logic Shared logic Shared UI

    Compose Multiplatform Swing Android Views SwiftUI
  11. Kotlin alapú szoftverfejlesztés VIAUAV41 Free Educational Licenses jb.gg/edulicense Kotlin Multiplatform

    jb.gg/kmp Compose Multiplatform jb.gg/compose Fleet jb.gg/fleet Kotlin Multiplatform Kódmegosztás pragmatikusan zsmb.co/talks Braun Márton [email protected]