Introduction to Kotlin/Native

5fe8f40633300a70ea088a594cb33031?s=47 Alec Strong
January 29, 2018

Introduction to Kotlin/Native

A short talk introducing Kotlin/Native, how and why it's used and where it might fit in Android Development.

Video to come

5fe8f40633300a70ea088a594cb33031?s=128

Alec Strong

January 29, 2018
Tweet

Transcript

  1. Kotlin/Native Alec Strong

  2. package com.sample import java.util.ArrayList object Main { @JvmStatic fun main(args:

    Array<String>) { val names = ArrayList<String>() names.add("Shawn") names.add("Matt") names.add("Alec") names.add("James") names.add("Egor") names.forEach(System.out::println) } }
  3. What is native? machine code

  4. What is machine code?

  5. What is byte code? machine

  6. What is managed code? byte
 machine

  7. What is unmanaged code? managed
 byte
 machine

  8. What is kotlin?

  9. Front End .kotlin Kotlin Compiler

  10. Front End .kotlin Middle End IR Kotlin Compiler

  11. Front End .kotlin Middle End IR Back End IR .class

    Kotlin Compiler
  12. Front End .c / .cpp LLVM

  13. Front End .c / .cpp Middle End IR LLVM

  14. Front End .c / .cpp Middle End IR IR Back

    End .exe … LLVM
  15. Front End .c / .cpp Middle End IR Back End

    IR .exe … LLVM Clang
  16. Front End .c / .cpp Middle End IR Back End

    IR .exe … LLVM Clang
  17. Front End .kotlin Middle End IR Back End IR .kexe

    … Kotlin/Native Compiler Konan LLVM
  18. Why?

  19. How?

  20. None
  21. None
  22. import java.util.ArrayList object Main { @JvmStatic fun main(args: Array<String>) {

    val names = ArrayList<String>() names.add("Shawn") names.add("Matt") names.add("Alec") names.add("James") names.add("Egor") names.forEach(System.out::println) } }
  23. import java.util.ArrayList object Main { @JvmStatic fun main(args: Array<String>) {

    val names = ArrayList<String>() names.add("Shawn") names.add("Matt") names.add("Alec") names.add("James") names.add("Egor") names.forEach(System.out::println) } }
  24. import java.util.ArrayList object Main { @JvmStatic fun main(args: Array<String>) {

    val names = ArrayList<String>() names.add("Shawn") names.add("Matt") names.add("Alec") names.add("James") names.add("Egor") names.forEach(System.out::println) }A }
  25. fun main(args: Array<String>) { val names = ArrayList<String>() names.add("Shawn") names.add("Matt")

    names.add("Alec") names.add("James") names.add("Egor") names.forEach(::println) }A
  26. None
  27. Kotlin Stdlib

  28. Kotlin Stdlib (And things built using kotlin stdlb)

  29. Kotlin Multiplatform

  30. Platform Agnostic Code

  31. None
  32. apply plugin: 'konan'

  33. konanArtifacts { program('foo') // executable 'foo' library('bar') // library 'bar'

    bitcode('baz') // bitcode file 'baz' interop('qux') // interoperability dynamic('quux') // dynamic library frameworkA('quuux')A//AObjective-C }A
  34. konanArtifacts { frameworkA('quuux')A//AObjective-C }A

  35. iOS

  36. • No swift header support • Enums • Generics •

    Value Types • Garbage Collection
  37. Garbage Collection

  38. Kotlin/Native