Kotlin Native

Kotlin Multiplatform

&

JVM

Android

Browser

Native

Kotlin Native

Kotlin Multiplatform

!=

Kotlin Native

Technologie um Kotlin Code zu nativen Binaries zu kompilieren, die ohne VM laufen.

  • Bestmögliche Integration in existierende Systeme
  • Einfache Anwendung
  • Nützliches Tooling

Kotlin Multiplatform

Technologie um Kotlin Code auf unterschiedlichen Plattformen
wiederzuverwenden.

  • Interoperabilität
  • Maximale Code Wiederverwendung
    • Über ein Kotlin Common Modul

Kotlin Multiplatform

internal expect fun writeLogMessage(message: String, logLevel: LogLevel)
internal actual fun writeLogMessage(message: String, logLevel: LogLevel) {
    println("[$logLevel]: $message")
}

Common

internal actual fun writeLogMessage(message: String, logLevel: LogLevel) {
    when (logLevel) {
        LogLevel.DEBUG -> console.log(message)
        LogLevel.WARN -> console.warn(message)
        LogLevel.ERROR -> console.error(message)
    }
}
expect
actual

Kotlin JVM

Kotlin
Compiler

Java
Compiler

Kotlin

Runtime

*.kt
*.class
*.java
*.jar

Kotlin JS

Kotlin
Transpiler

*.kt
*.js
*.map

Welcome
to the Native World

Kotlin Native / Native

Kotlin Native

  • iOS (arm32, arm64, simulator x86_64)
  • MacOS (x86_64)
  • Android (arm32, arm64)
  • Windows (mingw x86_64, x86)
  • Linux (x86_64, arm32, MIPS, MIPS little endian, Raspberry Pi)
  • WebAssembly (wasm32)

JVM

Android

Browser

Native

Kotlin Native

Kotlin
Compiler

LLVM
Compiler

*.kt
LLVM IR
*.exe

The LLVM Compiler Infrastructure.
IR =
 Intermediate Representation 

Kotlin Native

Pac-Man

Kotlin JVM

Kotlin Native

Kotlin JS

Android

Desktop

IOS

JAR

APK

Native Exe

Native App

Web

App

Demo Projekte

Kotlin JS

Game Wishlist

Kotlin Native

IntelliJ Launcher - Win 32 API

Kotlin Multiplatform

HitKlack Spiel - Korge

Kotlin Native

fun main(args: Array<String>) {

    val start =  getTimeMillis()

    var c = 0L
    var string = ""
    for(i in 0.. 100_000){
        c += (i / 2)
        c += 1
        string += c
    }

    println( getTimeMillis() - start)
}

BENCHMARK

Kotlin Native

[ millisekunden / run ]   weniger ist besser

Kotlin Native

Graal

vs

VM

Kotlin Native Graal VM
Fokus Interoperabilität Polyglot + Performance
Sprache Kotlin 1.3 Java 1.8, R, JS, Python 
Status Beta RC15
Platform Win, Linux, Mac, IOS, Android, Embedded Linux, Mac
Lizenz Apache License 2.0 GPL - Community  Ed.

Kotlin 💘 Dev

Kann alles 💪

Läuft überall

Cool 

Schnell

Einfach

Sicher

Macht Glücklich ☘

THE END

Quellen

Kotlin JS Beispiel - Game Wishlist

github.com/TobseF/KotlinJsGameWishlist

 

Kotlin Native Beispiel - IntelliJ Launcher

github.com/TobseF/IntelliJ-Launcher-n

 

Multiplatform Beispiel - Hit Klack - Korge

github.com/TobseF/HitKlack

Quellen