Kotlin’s 1.3 release enforce the concept of a multi-platform language, you already can use Kotlin to produce JVM binaries and JS bundles, it’s now possible to produce Native frameworks !

Kotlin/Native is technology for compiling kotlin code to native binaries, which can run without virtual machine Kotlin is used LLVM based backend for the kotlin compiler and native implementation of code Kotlin standard library.

What is LLVM, is collection of modular and reusable compile and toolchain technologies. LLVMis research project at the University of Illinois  

Why Kotlin/Native?

Kotlin is primarily designed to allow compilation for platforms where Virtual Machines are not desirable or possible. best example is embedded devices and IOS. It Solves the solutions when a developer needs to produce a self contained program that does not required any an additional runtime or Virtual Machines.

Not only IOS and embedded devices, Following Targeted Platforms also included.

  • iOS (arm32, arm64, simulator x86_64)
  • macOS (x86_64)
  • watchOS (arm32, arm64, x86)
  • tvOS (arm64, x86_64)
  • Android (arm32, arm64, x86, x86_64)
  • Windows (mingw x86_64, x86)
  • Linux (x86_64, arm32, arm64, MIPS, MIPS little endian)
  • WebAssembly (wasm32)

Interoperability

Interoperability is a characteristic of a product or system, whose interfaces are completely understood, to work with other products or systems, at present or in the future, in either implementation or access, without any restrictions. - Wikipedia

here kotlin support two way interoperability with native word one the other hand, the compiler create:

  • an executable for many platform
  • a static lib or dynamic lib with C Header for C/C++ project

In the case of a native platform, the most important interoperability target is C library, so kotlin/Native comes with a Cinterop tool, which can be used to quickly generate everything needed to interact with external lib.

following work flow is expected when interacting with the native library.

  • create a .def file describing what to include into binding
  • use the cinterop tool to produce Kotlinbindings
  • run kotlin/Nativecompiler on an application to produce the final executable

The  interoperability tool analyses C headers and produces a natural Mapping of the types, function & constants into the kotlin world. the generated stubs can be imported into an IDE for the purpose of code completion and navigation.