Kotlin’s push for total platform ubiquity is a remarkable engineering feat that risks overcomplicating the developer experience. It’s a brilliant demonstration of a language trying to be everything to everyone, for better or worse.
Deep Dive
Prerequisite Knowledge
- No data available.
Where to go next
- No data available.
Deep Dive
Run, Kotlin, Run! | Marc Reichelt
Added:All right. Let's get started. So, uh this talk is going to be really quick.
I'm Mark. I'm from Fertig. We're going to run Kotlin as many times as we can in 15 minutes. Let's go.
This is the code we're going to run. Uh is prime. The code really doesn't matter. So, we're just going to call is prime in many different uh contexts. And every time we run it, we're going to hit the bell.
And then, I got that from Duncan. Uh so, Duncan is also here at the conference.
He's not giving a talk, but you should uh see his talks like uh apparently Duncan is amazing. So, here we have the uh the the code. Uh we have uh multiplatform project. Here's the common module. We have the is prime function.
Let's start with the first one. So, we have the JVM module here. We have the main.kt. We can run this here. Running it on the JVM. And there we go. Uh we ran primes. First one. Maybe someone can count so I don't have to. Okay. Okay.
Okay. Okay.
Um then, let's go back to Let's go to Android. So, let's go to Android. Let's select Android here. Let's run it. So, here we have the Android device on the right-hand side. Let's run it. Does it run? Yes, it runs. Here we have 71 is a prime. Indeed, we have Kotlin running a second time.
And actually, uh this is uh you know, actually two because here we can go to the main activity. And of course, we have compose previews. Let's stop the emulator so it gives us a little bit more performance, which we'll need uh for Xcode to run. Uh so, here we have previews. Uh we have the code running here. Uh 72 is not a prime. So, let's actually run the run the Kotlin code another time.
That's already three times.
So, okay. Going to iOS. Uh this is really cool. We have the iOS app. It depends on the common module. Uh so, we can select iOS app here in Android Studio, which I think is just really amazing. So, we're going to run that.
Bam! Here's the iOS um simulator. It's running. Bam!
>> [laughter] >> Okay.
Kill the iOS simulator. Xcode. Here we have Xcode and we have Swift UI previews. We can change the code here.
So, indeed we can run Kotlin in Swift UI previews. That's another That's another time.
>> [applause] >> Okay, let's close Xcode.
Good.
So, with that Okay, now I will be much more relaxed. Okay, perfect. So, we have five ones.
Let's actually Okay, so we can run Kotlin of course in Gradle. So, here we have a build.gradle file which basically takes input directory. We have different files which are named like numbers. So, we're going to copy only the files which are prime. So, here we call the isPrime function which we have here in the Gradle module. So, I have the readme here.
We can run that. Bam. Let's see if it runs.
And and it's run. So, let's actually see.
So, we have the build folder here. We have the prime folder here. So, we have prime numbers. We copied the files with the prime numbers. Okay. [applause] Let's close that one.
Okay, next up is the playground. So, really cool. Even if you're on the mobile phone or on the one if you have internet, you can run Kotlin. So, here we have the Kotlin playground which I think is really cool. So, here let's actually open that up a little bit.
Increase the font size. So, here we have the is primes online on play.kotlinlang.org.
We're going to run that, get some prime numbers, and there we go. It ran.
Okay, very very cool also here. Note you can switch also backends. You can switch to JS, WASM. You can run that as well.
I'm not going to count that because it's still the Kotlin playground, but I think it's pretty amazing because you can just play with the different technologies online on the Kotlin playground which is kind of cool. Woo. Okay.
Let's go back. Let's Okay, next one up is macOS. So, with Kotlin native you can compile macOS binaries. So, you can actually compile programs like you would for example like a C or C++ or like a Rust program. So, here we calling the common code. Uh it's basically just the main function. We are We already compiled um the is prime file. So, we can actually run that in the terminal. And there we go. We have the primes running Kotlin native for Mac OS. Go.
Okay.
>> [applause] >> And also Kotlin native is really cool because you can also compile it for Linux and so on. But I have a Mac, so what do I do?
Uh so, here we have um the the main.kt. Uh we can actually use Docker Docker to just to run the executable. So, here I'm going to ask what I'm Docker just to run in Ubuntu.
And here we have the uh file which is which we just import from from the local directory. Uh we're going to run that.
And and there we go. We have Kotlin native running in Linux running in the Docker image on a Mac.
That's a >> [applause] >> There we go.
Okay. Now we go to the next one. Also, this is really cool. So, here we have in the build directory um we have the binary. So, here we have the is prime.exe file. How do we do with that um on the Mac? I mean, we could run the whole Windows, uh but we don't need to. Luckily for Linux and Mac, there's a tool called Wine, which you can just install. Uh and then you can run that.
So, we're going to run that one here so we don't get the warnings. There we go.
The Windows exe file with Kotlin native code running on a uh you know, in Wine on a Mac. There we go. We have primes.
>> [applause] >> Did somebody count? I lost track. Sorry.
Um okay, let's go to the next one.
Scratch files. Uh really useful tool in in IntelliJ. Uh if you want to scratch file, you just type command shift N or you just type double shift and then you say scratch file.
So, we create a new scratch file uh with Kotlin in this case. Uh so, here we have Kotlin and let's just copy paste the thing from the readme. So, here we have uh we're calling the is prime function.
So, let's go back to the scratch file.
Here we go. It's not finding the is prime function because we need to select a class or module. As you can see, I have many modules here in this project, which is basically killing my myself on stage. So, let's actually type JVM main.
Let's use this one. Then we can find the is prime function. We're going to run that. Running Kotlin in a scratch file.
Let's see if we can do it. Oh, yeah, we got the result here. So, bam, running in a scratch file.
>> [applause] >> Okay. Now, also, I mean, if you worked with Gradle, you notice like the KTS extension, but you can also run KTS files like like script files on your machine locally.
So, you can just do a KTS file, run your code here, and then you can right click.
I love the IDE integration.
This is like a celebration of all, you know, like Kotlin, like where we can run Kotlin. So, here we have the Kotlin script file running on the local machine.
And you can also call that just directly from the terminal, which is also really cool. Just type Kotlin. So, if you installed the Kotlin native tooling Kotlin, sorry, command line tooling, then you can just type Kotlin, and then the file, and then it's going to run.
But then I wondered actually, okay, so here we have the same KTS file, but can we actually run that as an executable on on the shell? And actually, you can. So, this is weird, because usually this this sign is like not allowed in Kotlin, but if you type this at the very first line, it's actually as a comment. So, that means that we basically say, "Hey, we use Kotlin." So, like a best script, we can make this file executable now.
So, let's actually open this in the terminal.
Open in terminal. Open. I need to type right correctly. Open in terminal. There we go. Okay, now we type dot slash to execute it, primes.kts.
And the Kotlin tool will come over. It's going to run the code. There we go.
Okay, we have some prime numbers.
And what's really cool also about the native tooling, let's actually open up the terminal again.
So, with the native tooling, you can also just if you want an expression like for example you have like a really hard math equation like this one. Then you can type that in. Sorry, I need to copy paste correctly.
Okay, there we go. 6.7 * 7 is like 42.
That's running. Okay, so we can also type a little bit more things but you can also run the Kotlin REPL which is an actually let's decrease the font size here a little bit so you can see this better. So, here we going to execute the Kotlin REPL which is basically a thing that you can use to just dynamically run the code. So, here we go. We will copy over all the things here.
So, where do we go? So, from the prime.kts file so the thing that we just ran and we're going to type it here so we can just you know, type Kotlin here. There we go. The same code running in the Kotlin REPL on the terminal.
Okay, so next one.
As you can see I used to forget to show the REPL so that's why I have the file here.
So, here we have Kotlin JS which is really cool. So, here we have JS so it depends on the common module so it depends it will create two different variants like browser and node JS. You can you can run it in the browser and you can run it on the command line with node a node.
So, this is really cool so we going to also love the idea integration. You just hit the run button.
JS browser development run so we're going to open the browser. There we go.
Okay, now we going to see open the console. There we have the primes running in the browser.
And then we're going to stop the Gradle task, run it again but this time with node on the command line. So, we're going to run it and there we go. We have the primes here on the command line with node.
And this is basically compiling Kotlin to JS so this is using JavaScript and I noticed that actually if you find primes with JavaScript that's actually kind of slow but we have web assembly so let's actually use that one.
So, here we have web assembly and here we actually have three targets. There's a new one. And I'm going to go into that uh pretty soon. So, here we have the target browser, we have the target Node.js. It's going to look the same, but it's going to be execute much faster. So, we're going to run the same thing here. So, we have the web main target, which is basically uh for browser and node. So, here we're going to run in the browser again, uh but now the WebAssembly uh find finding primes faster. So, here we go. We have the terminal, if it opens up. Here we have the primes running with WebAssembly in the browser. And you can use Compose, of course. Compose multiplatform also run uses this this technology to run it the browser. So, it's much faster.
Uh and now we're actually going to stop that again, run it again in Node.js locally.
So, again, WebAssembly, but now running locally, so also pretty fast. So, we have it in node with WebAssembly running on our machine.
And now, this is a really cool technology. So, uh with WASI, we can actually use system interfaces. So, here we have a system interface which we're going to use, which is defined like it's So, it's called clock time get. So, we're going to get the system clock from WebAssembly and call the is prime function on it. Why not?
Uh so, uh this is using some weird, you know, memory allocator. So, we you know, because it's very close to, you know, the the way like with C, we actually do some pointer arithmetic here. Um I didn't come up with the code. It's online. So, this was really helpful. Uh but now, we're actually going to repeat 1,000 times call the um call the clock.
So, this function WASI get time, which is basically then calling the the interface, the WASI interface clock time get.
Uh can I run this in here? Yes, I think I can. So, I will just run this here.
No, I think this doesn't work. So, I need to use the Gradle task. So, here we have WASM uh so, we can run it with WASM time. So, here we have WASM WASI node production run. Let's call that.
And now, we're going to Yep, here we have no prime numbers there we found found the current time, which is a prime and it's a rhyme.
>> [laughter] [applause] >> And now, also really cool technology, we have Kotlin notebooks, with which you can create charts, you can import data, you can do data operations on this one.
Um so, here we have the is prime function. You can have um more code snippets. So, here we have like a one more, one more. Uh you can run that code here. Uh there we have the is prime function, but you can also type like, "Okay, is prime seven." You can do charts and everything. I think this is really cool. So, calling is prime seven, yes, true, it's a prime. So, yeah, kind of cool. Kotlin notebooks. Um and also something that many people don't really know about. So, um if you're in the in the debugger, um did I Yeah, I I I think I hit the bell. Um so, if you're in the debugger, so look at this main function. It has nothing.
This module even doesn't have a dependency on on the um other modules.
So, I will just copy paste this code here.
So, just show off what the what it can do. So, we can actually debug the this uh function. Now, we are in the debugger, and uh this one only allows you to to enter single-line expression, but you can actually evaluate expression, make it bigger, make it bigger.
Here we go. And yeah, so here we here you can see it's actually running and then evaluate. Now, we have Kotlin running in the debugger.
>> [applause] >> And And what's really cool about this, so you can do functions, you can do data classes. So, there's lots of things allowed. So, I just uh you know, this is really cool. So, um and also you can select Java if you really dare to. Um but, okay, let's So, that's the debugger.
Um let's stop the debugger.
And uh that was basically all the different things that I wanted to show.
But, uh what's also really cool here is um So, I actually have um So, in In module, you can see there's a common test. And as you can see I I have all these different folders here. Why is that? Uh because we have the prime test, and uh actually when I try to compute um the primes on JavaScript, it actually failed because it ran into a timeout.
So, I just said, "Okay, I'm going to use is js true for the JavaScript targets, and for all the other ones like WebAssembly, it just will uh will call it anyway." Uh so, we don't just going to skip skip the test. And what I think is really cool here is the tooling. So, we're going to run the prime test here.
Select all the different things. So, here you can see Android, iOS simulator, JavaScript. It's actually going to launch a browser. It's going to launch the macOS terminal application. Running that. And uh here we go, running on many different platforms at the same time with a single unit test, which I think it's amazing. So, we're not going to count it, but I'm going to hit the button anyway because it's just so nice.
>> [applause] [cheering] >> And oh my good, we are completely in time. That's amazing. I didn't expect that.
Uh okay, very good. So, um basically, if this was way too fast for you, thankfully there's a recording, so you can just uh you know, crunch it down by like 50% or something. And you can find the code there on github.com/mreichelt/run-kotlin-run.
And with that, have a nice Kotlin.
>> [applause]
Related Videos

TOP 15 Data compression Interview Questions and Answers 2019 Part-2 | Data compression | Wisdom jobs
wisdomjobs
281 views•2019-06-28

CTS 158: 802.11w Management Frame Protection
ClearToSend
4K views•2019-02-04

NDSS 2019 Send Hardest Problems My Way: Probabilistic Path Prioritization for Hybrid Fuzzing
NDSSSymposium
496 views•2019-04-02

How realistic is Cities: Skylines?
CityBeautiful
159K views•2019-02-14

GUIs & TUIs: Choosing a User Interface for Your Python Project | Real Python Podcast
realpython
2K views•2025-04-04

The OSI Model - Explained by Example
hnasr
225K views•2019-05-12

Cloud Computing - Introduction
elithecomputerguy
98K views•2019-10-07

From Traveler's Dilemma to Dynamic Routing | Demystifying Networking
IITBombayJuly
5K views•2019-08-04
Trending

WOW! Judge TURNS THE TABLES on Trump in His OWN $10B LAWSUIT!!!
MeidasTouch
197K views•2026-07-23

Playstation NO DISC/NO BUY Fight Is Over...
DavidJaffeGames
4K views•2026-07-23

Steam and Xbox Just Dropped The Hammer On PlayStation
OhNoItsAlexx
9K views•2026-07-23

Americans Confused in Australia for 17 Minutes Straight
IWrocker
17K views•2026-07-23