· 3 min read Posted by Kevin Galligan

Notes from the Kotlin Native Frontier

(Crosspost from medium.com/@kpgalligan)

Obviously, the Android community has been talking quite a bit about Kotlin. I won’t get into that. It’s cool, but let’s call it well handled by others. I’m going to talk about what’s showing up in the Kotlin/Native samples folder!

My particular career focus has shifted dramatically in the past 1–2 years and is pretty much on code sharing and how we’ll be pushing pixels for the next decade (ish). I don’t know exactly how things will shake out, but we’re talking to a lot of people who are trying different ways to not build the same thing over and over again.

We have built Doppl. It’s a mobile code sharing tool. It is interesting now because it’s available now, and will fit well into a lot of contexts. It’ll be a bit, but you will be able to code Android, JS, iOS, and apparently sooner than I thought, webassembly, with Kotlin code. If we had a current “focus”, those two would be it.

We’ll save the “yeah, but what about ____?!” discussions for later. Assume there will be multiple “things”, and not everybody is going to agree with you. That’s how people work.

I’m speaking at a Swift conference in November, and my talk is basically saying the web and Android communities are working on their answer for other screens. The Swift community should do the same.

Anyway, you can’t really deploy Kotlin on iOS yet, unless you’re doing a hacky Javascript thing, or embedding a JVM. That is going to change, though. I cloned the most recent Kotlin/Native build to play around with samples. I’ve seen the iOS stuff work, but hadn’t seen the webassembly sample!

Webassembly

Webassembly is a browser standard that will allow you to distribute web logic as binary assembly, compiled from llvm, rather than Javascript source. Its new, although all major browsers have a functional implementation. The features on the future roadmap are definitely compelling (threads, for example). It may wind up being more of a niche technology for situations that require high-end performance, but it would also allow many languages to be deployed “directly” to the web. See how that goes.

This sample is not what I’d call “practical”. You can’t use this today. However, it’s the first Webassembly thing I’ve ever built (I just built the sample, and did a little Kotlin tweaking to make sure it actually worked).

http://doppl.co/wasm/index.html

It takes a while to load. Like I said. Not practical today, but assuming you’re on Chrome, this works (haven’t tried other browsers).

UiKit

Kotlin Native can “mount” Objective-C headers for interop. The sample compiles and runs on iOS, which is cool, but hopefully, for you can build a separate library that can be referenced from Swift, etc. I keep advocating this because I think it’ll be very important for adoption.

This is all very neat stuff! It’ll be a while before the tooling allows you to be productive, but it’s coming.

Happy Friday! Come to Droidcon SF!