Garth Gilmour | KotlinConf 2024, May 22–24, Copenhagen
all speakers

Garth Gilmour

Garth Gilmour

Garth Gilmour - Developer Advocate at JetBrains

Garth Gilmour was a full time developer for 5 years and then an educator / mentor for 20. Currently he's a Developer Advocate at JetBrains. He's taught well over 1000 courses and workshops - using everything from CORBA to Kotlin. Garth is a prolific speaker, writer and co-organiser of several conferences and meetups. When not at the whiteboard he coaches Krav Maga, lifts heavy weights and fights nerf wars with his kids.

Kotlin Multiplatform Beyond the Basics

This is an intermediate / advanced workshop for experienced Android developers. It is aimed at engineers who have built projects with Kotlin and Jetpack Compose and now want to progress onto multiplatform application development.

The workshop is split into two parts. In the morning session, we’ll build an application entirely using Kotlin Multiplatform libraries. This will feature a Compose Multiplatform user interface, testing with kotlin.test and Kotest, and networking with Ktor and coroutines. Additional libraries will be used to show data caching, dependency injection, serialization, and more.

In the afternoon session, we’ll explore real-world issues associated with taking these kinds of applications into production. We’ll explore general issues with architecture and deployment but then shift our focus to issues specific to iOS. In particular, we’ll cover how best to package and expose Kotlin APIs to be consumed by Swift code, and vice versa. We’ll also explore how to share business logic with a SwiftUI interface, work with XCode, and distribute your application.

Morning Topics

  • Review the basics of KMP development.
  • Introducing the workshop sample application.
  • Adding shared business logic with unit tests.
  • Platform integration with expected and actual declarations.
  • Extending the existing Compose Multiplatform UI.
  • Interacting with services via Ktor and coroutines.
  • Creating integration tests at different levels.
  • Refactoring the app to use dependency injection.
  • Adding client side caching to improve performance.

Afternoon Topics

  • Best practices for building multiplatform applications.
  • Guidelines for creating and distributing your KMP library.
  • Making the most out of the existing KMP ecosystem.
  • A primer for using XCode effectively in KMP apps.
  • Effectively sharing Kotlin APIs with Swift codebases.
  • Mixing Compose Multiplatform and SwiftUI components.
  • Options for testing a Compose Multiplatform UI in iOS.
  • Distributing your shared code to iOS teammates.

Managing Complexity With Ktor

Many teams use Ktor solely to create and consume RESTful services over HTTP. They build modestly sized microservices and clients that perform a limited set of tasks well. Whilst these are completely valid use cases, they only scratch the surface of what is possible with Ktor.

Ktor includes support for Server Sent Events, WebSockets and kotlinx-io. These technologies allow you to incrementally stream data from client to server, such as when reading tokens from an LLM. You can also implement bidirectional conversations, recover from errors, and implement your own buffering strategies. At a higher level, in the design of your applications, you can use Dependency Injection frameworks like Koin, Kodein and Hilt to create and inject the correct networking client, repository, cache etc… for the current environment.

This talk will demonstrate how to configure Ktor Server and Client for a range of non-trivial tasks. You will see how to make best use of both existing, external libraries and upcoming enhancements to the framework itself.