Kotlin Native Coroutines Preview
Tags: kotlin, kotlinmultiplatform, android, ios
Published: 2019-11-15 18:42:37

---
title: Kotlin Native Coroutines Preview
published: true
description: The arrival of Multithreaded Coroutines for Kotlin Native means a big blocker to progress has been removed.
tags: kotlin, kotlinmultiplatform, android, ios
---

---

Very recently, a [draft PR (#1648)](https://github.com/Kotlin/kotlinx.coroutines/pull/1648) landed in the [kotlinx.coroutines github](https://github.com/Kotlin/kotlinx.coroutines) that will enable multithreaded coroutines in Kotlin Native (KN). *This is a big deal for the technology, and a lot of people have been waiting for it*. I tweeted a little screenshot, and just that got a fair bit of attention

{% twitter 1195083478825684992 %}


It is not a stretch to say a lot of developers have been waiting for this, as one of the tweet replies highlights:

{% twitter 1195376410522738688 %}

To be clear, as much as this is a good thing technically, I think it's a big deal psychologically. You could achieve concurrency before multithreaded coroutines, and there are certain to be issues as the implementation emerges. However, a lot of people were waiting for this. There are technical reasons people were waiting, but in a more general sense, it's a reality signal. *Multithreaded Coroutines make Kotlin Native more "real"*. In the JVM world, coroutines have been dominating the conversation around concurrency, so the lack of "full" coroutines in native was a signal that it's wasn't ready, or not a priority. That is changing.

What does this mean? In short, a big block to adoption has been removed. There's a lot of library work around architecture and concurrency that hasn't been happening because those implementations would largely be obsolete once multithreaded coroutines emerged. That block has been removed. *We should expect a lot of follow-on library work, tech talks, and blog posts. Shortly after that, a lot of production deployment*.

> In short, a big block to adoption has been removed.

There has also been uncertainty around the threading model. Going back to the summer, the Kotlin Native repo got an experimental addition. [Relaxed mode](https://github.com/JetBrains/kotlin-native/pull/3129). It essentially let you access shared memory just like you can in the JVM. Whether that is a good thing or not is a much longer debate ([which I'll be talking about at Kotlinconf](https://kotlinconf.com/talks/5-dec/127136/)). However, a lot of the community assumed relaxed mode existed in preparation for multithreaded coroutines. If relaxed mode became popular, it would probably end strict mode, but it was unclear which way things would go. There was a lot of uncertainty.

The uncertainty around Kotlin Native's state model is gone. Multithreaded coroutines work within the strict state model of Kotlin Native. That means although relaxed mode may be supported in the future, it is not the primary direction of the platform. Strict mode is here to stay.

> The uncertainty around Kotlin Native's state model is gone.

We are currently in the middle of November. PR #1648 is still working it's way through completion. I would assume there is some release by Kotlinconf, which is ~3 weeks away. Just in time for people taking holidays to poke around. I'd expect to see a bit of activity in the community before the new year.

We will be doing an update to the [DroidconKotlin app](https://github.com/touchlab/DroidconKotlin/), using a few new libraries and, of course, multithreaded coroutines. Hopefully, we'll have a version of that out before Droidcon SF, but if not, sometime in December.

This is also a good time to tell you about our [KaMP Kit](https://go.touchlab.co/KaMP-BL). We've been talking to orgs evaluating Kotlin Multiplatform who have had some trouble getting started. The platform is moving fast, and there's a lot of conflicting or outdated info out there on the web. The KaMP Kit is a set of starter repos and documentation to get you set up for success quickly. Our first version will be released in mid-December. [Go here](https://go.touchlab.co/KaMP-BL) to sign up for early access.


---

Touchlab is hiring mobile engineers excited about Kotlin Multiplatform. We are a remote friendly org. [Come check that out](https://go.touchlab.co/971) if interested.