68
Live Coding Kotlin/Native Snake @dmitrykandalov github.com/dkandalov/kotlin-native-snake

Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

  • Upload
    others

  • View
    48

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Live Coding Kotlin/Native

Snake@dmitrykandalov

github.com/dkandalov/kotlin-native-snake

Page 2: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 3: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

⚡ Lightning talk ⚡

Page 4: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

What isKotlin/Native?

Page 5: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 6: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 7: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime

implementation, and native code generation facility using the

LLVM toolchain.

Page 8: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

🤷

Page 9: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime

implementation, and native code generation facility using the

LLVM toolchain.

Page 10: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 11: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Page 12: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Page 13: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Compiler frontend

Page 14: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Compiler backend

Page 15: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Compiler backend

Page 16: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Compiler backend

Page 17: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime

implementation, and native code generation facility using the

LLVM toolchain.

Page 18: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

LLVM

Page 19: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 20: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Kotlin/Native

Page 21: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Kotlin/Native

LLVM IR

Page 22: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

IR

Kotlin/Native

LLVM IR

Done by LLVM

Page 23: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

C/C++ (clang)Objective-C

RustSwiftJulia

Graal VM

Page 24: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime

implementation, and native code generation facility using the

LLVM toolchain.

Page 25: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

kotlin.String java.lang.String

Page 26: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

kotlin.String java.lang.String

JS string

Page 27: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

kotlin.String java.lang.String

JS string

KString

Page 28: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

kotlin.* JVM

JS

Native

Page 29: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

- reference counting- native-specific code

Page 30: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime

implementation, and native code generation facility using the

LLVM toolchain.

Page 31: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 32: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Why?

Page 33: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

1. Performance

Page 34: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 35: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

2. C APIs

Page 36: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

- POSIX - native OS UI

- interop between languages- C libraries

(search for “awesome-c“)

Page 37: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

3. Kotlin

Page 38: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

End of the ⚡Lightning talk ⚡

Page 39: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 40: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Live coding

Page 41: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 42: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 43: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Disclaimer:Very few unit tests

😓

Page 44: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Disclaimer:This is a happy

path 🌈🦄

Page 45: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 46: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

There are more native things…

Page 47: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

- C and Objective-C interop- concurrency with workers

- object.freeze()-object.pin()

- @CName, @ThreadLocal

Page 48: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

- memory leaks- segmentation faults

Page 49: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Takeaways

Page 50: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 51: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native

Page 52: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native

RustScala Native

Page 53: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native

RustScala Native

Page 54: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

github.com/dkandalov/rust-snakegithub.com/dkandalov/scala-native-snakegithub.com/dkandalov/go-snake

See also:

github.com/dkandalov/graalvm-snake

Page 55: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

It’s early daysfor Kotlin/Native

Page 56: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

- slow compilation 😴- only CLion & AppCode- tools are not perfect yet

Page 57: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

What can you do next?

Page 58: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 59: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 60: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 61: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 62: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 63: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 64: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

Kotlin/Native 😎

Page 65: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain
Page 66: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

The End@dmitrykandalov

github.com/dkandalov/kotlin-native-snake

Page 67: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain

The End

@dmitrykandalov

github.com/dkandalov/kotlin-native-snake

Page 68: Live Coding Kotlin/Native Snake - JetBrains...Kotlin/Native is an LLVM backend for the Kotlin compiler, runtime implementation, and native code generation facility using the LLVM toolchain