Kotlin Native Fast Track

Kotlin is an excellent option for JVM development is now the preferred language for Android. Using Kotlin Native while working with platforms where Virtual Machines are not applicable can be your best choice because Kotlin is a powerful yet simplistic language. 


Kotlin Native makes use of LLVM to generate native instructions that run on the target platform, such as MacOS, ARM, and WebAssembly.


What You’ll Learn

➜ How to use Kotlin with native applications and libraries written in C, C++, Objective-C, Swift

➜ How to generate Kotlin library wrappers using headers from other languages 

➜ How to consume Kotlin Native libraries from other environments

➜ Learn about the wider Kotlin ecosystem and create multi-platform projects for JVM, Android, JS and Native platforms

➜ How to use Kotlin to create native apps, frameworks and libraries

➜ How to build hierarchical Gradle multi-platform projects


➜ We recommend that attendees of this course have knowledge of Kotlin.

➜ Basic knowledge of C and C++ terminology is recommended but not required. 


Course Outline

Kotlin Native – Introduction
  • Expanding Kotlin beyond the JVM
  • Understanding the LLVM Compiler Tools
  • Platforms supported by Kotlin Native
  • JVM functionality not available in Native
  • Choosing between the CLion and IntelliJ IDEs
  • Deconstructing a simple native project
Interoperating with C Libraries
  • Working with the provided platform libraries
  • Importing headers from external C libraries
  • Making sense of Kotlin types for native data
  • The role of CVariables, CPointers and CValues
  • Exchanging string data between Kotlin and C
  • Representing C data structures using CStructs
  • Memory management via alloc, free & memScoped
  • Invoking Kotlin callacks from C and vice versa
  • Using StableRef to extend object lifetimes
Interoperating with Objective-C / Swift
  • Working with the provided platform libraries
  • Importing headers from Objective-C / Swift
  • What Swift features are not supported
  • How Swift APIs are mapped to Kotlin
Multithreading and Coroutines
  • The risks of shared mutable state
  • Limitations on sharing data across threads
  • Initialising the runtime when creating native threads
  • Utilising Kotlin’s built-in Worker type
  • Consuming results via Future objects
  • Freezing data and breaking the rules using the Atomic types
  • Transferring object ownership between threads
  • Limits on using coroutines in Kotlin Native
Creating Multiplatform Gradle Projects
  • Choosing between the Groovy and Kotlin DSLs
  • The Kotlin Multiplatform Gradle Plugin
  • Targeting different native platforms
  • The default folder naming conventions
  • Specifying repos and project dependencies
  • Controlling compiler and linker options
  • Creating hierarchies and sub-project