Slide 1

Slide 1 text

Kotlin Multiplatform

Slide 2

Slide 2 text

Kotlin Kotlin/JVM Kotlin/Native Kotlin/JS Kotlin Multiplatform Easter Egg

Slide 3

Slide 3 text

Kotlin Kotlin/JVM Kotlin/Native Kotlin/JS Kotlin Multiplatform Easter Egg

Slide 4

Slide 4 text

Warning: The next slides are not 100% accurate but give you a visualisation about how Kotlin Multiplatform works

Slide 5

Slide 5 text

Fact: Kotlin is a Programming language.

Slide 6

Slide 6 text

Fact: Each language has to converted to something which can be understand by "a computer". We call these converters compiler.

Slide 7

Slide 7 text

Fact: Jetbrains provides different compilers for one language.

Slide 8

Slide 8 text

Fact: Jetbrains provides different compilers for one language. 1. JVM 2. Native 3. JS

Slide 9

Slide 9 text

Fact: Kotlin can be converted to Java Bytecode (via JVM compiler) Machine code (via Native compiler) JavaScript (via JS compiler)

Slide 10

Slide 10 text

fun main() { println("HelloWorld") } Example $ kotlinc HelloWorld.kt -include-runtime -d hello.jar $ java -jar hello.jar HelloWorld $ konanc HelloWorld.kt -o hello $ ./hello.kexe HelloWorld $ kotlinc-js HelloWorld.kt -output hello.js $ cat hello.js // JS Code nobody wants to see

Slide 11

Slide 11 text

Please note that we talk about pure Kotlin code. No dependencies to other worlds (like JVM, C or JS).

Slide 12

Slide 12 text

But - because the compiler knows about other worlds it is possible to use the respective dependencies!

Slide 13

Slide 13 text

Example expect currentTime: Long fun printTime() { println("It is $currentTime o'clock") } common.kt // No dependencies to other worlds actual currentTime: Long = java.lang.System.currentTimeMillis() fun main() = printTime() jvm.kt actual currentTime: Long = platform.posix.time(null) fun main() = printTime() native.kt actual currentTime: Long = kotlin.js.Date.now() fun main() = printTime() js.kt

Slide 14

Slide 14 text

Now we can compile each target (jvm, native, js) with the respective compiler

Slide 15

Slide 15 text

Questions so far?