 As you can see, my name is Mentor Stepan and now I'm working in Grapp and also I'm an organizer of Kotlin Singapore user group. So if you want some Kotlin stickers, you will be here on my table. Today we will talk about Kotlin native. So before we start, if you have a notebook and want to try the samples, I will show you. Please install IntelliJ, CI and NLJS or at least IntelliJ or CI. So in this case, you will be able to run some samples and try Kotlin native by yourself. I will talk about Kotlin, so some things were already covered, but not everything. Kotlin is not just a language. It's already a pretty huge platform that supports JVM JavaScript and LVM compilation. Basically that means that you could use Kotlin to write almost any kind of app possible from the JVM applications that will run on servers to Android applications, iOS and embedded systems. So far, as a platform, Kotlin have language, these compilers I just talked about. Also it have an option to interact with Java code as well as C code, Objective C and in the latest version of Kotlin native you could even access some Swift object and methods. As a platform it has a lot of IDE plugins. This was already covered in previous talk. All these IDE plugins help you a lot with writing new Kotlin code and there is Kotlin annotation processor and many, many more pretty cool tools that will allow you to write your Kotlin code faster and with better quality. So yeah. Kotlin is not limited by these areas. It also runs on, you could compile Kotlin code to run on WebAssembly which is like new technologies for browser which will allow you to run apps in browser with native performance. And as a good addition, Gradle also supports Kotlin right now so for those who don't know what is Gradle, Gradle is a pretty powerful build system. So to build large applications, simple compilation not enough anymore and especially on big projects you need a lot of tooling around that and Gradle allow you to do that with Kotlin of course. Yeah. So a bit of spoilers. I will be talking about Kotlin native today and it's not officially released yet. It's still the early pre-alpha stage. Things that works already, it's stable but still API could change and many of the things that accessible in Kotlin for GVM and Kotlin.js is not available for Kotlin native yet. Kotlin native it's like a platform that will allow you to build Kotlin code using LLVM compiler. LLVM it's so-called low-level virtual machine that used to compile languages like C, C++, Rust and many others. What it does, it translates your code into very low-level representation and then there is a compiler for every platform including Windows, Linux, iOS and even Android that will allow to compile this intermediate representation to the native binaries for the particular platform. What it means in simple words, it just means your code will be running very fast and almost everywhere. One more benefit of Kotlin native is that since Kotlin already supports a lot of platforms it's kind of natural that you could share the code between them. For example, on the latest Kotlin Conf there was a Kotlin Conf app that actually used Kotlin for virtually everything. There is an iOS application written in Kotlin, there is Android application written in Kotlin. There is a backend server that also written in Kotlin and the web app that written in Kotlin as well and later translated to JavaScript. This is kind of a structure of this project. You will have a common module that contains Kotlin code that is shared across these platforms. It basically means that if you need to write web, Android, backend and iOS you need to write code that is necessary for all these platforms, only once. So basically for some piece of code you save 75% of effort. Of course not 75% for now because you still need to set up the tooling and fight some nasty bugs. But yeah, guys is working pretty hard on that and so far I think it's one of the few, if not the only one platform that allows you to do that. Now I will be running some demo, a bit of spoilers. This demo could not fully work, as I said it's still like very early stage, but I will try my best to show it to you. Okay, yeah let me show you the GitHub page, yes. Basically this is the project that I was just talking about. This is the Kotlin Conf app, it's fully open sourced. As you can see here, this is Android, backend, JavaScript, iOS, web models that you could run. If you want to play with that, just go to this GitHub page, GitHub slash JetBrains slash Kotlin Conf dash app and give it a try. As you can see I already did that, so I have this project right here. So now we will try to launch it. Let's start with Android maybe and see if it will work. While I'm launching Android app, I will also launch the web app as well. So the web application ran on the Node.js and also I will run the backend. So you could notice here to build this project, I use Gradle. For the Kotlin native you could use two build systems that currently support you now. One of it is Gradle and the second one is the CMake files. So if you really want to use that, you will need to choose between Gradle and CMake. I would recommend it to use Gradle for the project that already use Gradle or doesn't use any build tools yet. For the CMake, it would be projects that already use something like CC++ or other native languages because the CMake provides you the better compatibility with the C++ environment. So now the backend is running and I'm trying once again to run our web server. Yay, it's working now. See this application, it's just a small app that shows you schedule of talks on Kotlin conference. The conference has sent it already and this example wasn't updated for around like 5 months. But still, this whole web application was written in Kotlin. We could go through the source code a little bit. So I will not go into details of how it's done. The thing is, there is already a lot of libraries for Kotlin JVM and Kotlin web. Not so much for Kotlin native yet because it's not released. So you could use all these libraries and even Java libraries and JavaScript libraries to create your Kotlin applications. Here for example, this is a Java backend. But if we go into the web, we could see here this web application was built using Node.js and here we could see some React wrappers on top of JavaScript that allows Kotlin to use React APIs to build this UI. And yeah, basically that's it. So if you want to save your lot of time by sharing the business logic and some pieces of code between JVM and JavaScript, you could do that already. It's already supported and working 100% stable. All the features that accessible on a JVM, most of them accessible on the JavaScript, the only difference would be this standard library is a bit different. Kotlin has pretty good compatibility with Java. It will have all the Java, all the JDK compatibilities in there. But for JavaScript it's not true. And if you use some Java code, you need to make sure you only use Kotlin standard library functions or you know how to implement the same thing in JavaScript. It should be pretty simple and I know a lot of people who are already doing that, including the guys who develop Kotlin. So for now they're building the IntelliJ IDE using Kotlin, all the websites that they launch, like new ones, using Kotlin as well. And yeah, the only problem remains is that how you will structure your code in the way that you could really reuse these parts. So this is why structure looks like this complex. Because these three models, common, common JVM and common JS, it's the containers for reusable code. So you need to know how you really want to reuse it and you need to make sure that this code is reusable, which for many projects from my experience is not true. Mostly developers don't think about reusability and just would worry about working in there, copying from Stack Overflow. So yeah, let's try to launch the Android app. For those of you who are not familiar with Android development, this is an IntelliJ plugin that supports developing Android apps. In this plugin you could create the Android emulator, which is basically kind of mobile phone on your desktop device. It emulates a lot of mobile phone functions, including calls, GPS, Bluetooth, and things like that. So we're launching that. You can drag it from the bottom bezel. Yeah, yeah, yeah. The bottom bezel, yeah, you can drag it from there. Oh, they changed it. Nice. Thank you, man. I haven't used the simulators for a long time already. OK, now what we'll try to do is we'll terminate our servers using Gradle. We'll just try to compile and install it. We actually just did that. We installed Kotlin application that used code shared across many platforms to our emulator. OK, where is it? Yes, this is it. So it's pretty nice looking application, I could say. You could expect all these fancy Android animations and all native Android components, including all frameworks that are accessible to Java. It's also accessible to Kotlin. So yeah, I wish I could show you the iOS application, but for some reason I can't build that. So this was expected. Since the technology is not in production yet, let me try once again. Still not working. Sorry for that, guys. But I hope if you will try it on your own and you have a bit of experience with iOS, which I don't, you could fix this nasty errors and try it myself. It would look very close to this application, but with all the iOS native components and things like that. The thing with Kotlin that, unlike other languages that try to be cross-platform and, for example, React Native that allows you to use JavaScript and allow you to use the single code base that built applications for Android and iOS, approach taking by Kotlin is a bit different. You actually, you can use single code base, but for now it would be like pretty tough and you need to do a lot of groundwork to do that. But the main idea is to integrate with existing ecosystems. For example, if you use Kotlin for the JavaScript apps, you will be using Node.js and NPM to get the libraries. And then you could use it from Kotlin. You will not have some cross-platform libraries. But yeah, of course, there would be. It's possible to do. But it's not the official proposed way, I would say. So far since Android is pretty young, so it was first, like alpha version was released around 2012. But still, like for technology, this thing that covers this many platforms, it's very early stage, I could say. And integration with existing ecosystems, for me, looks like a very good strategy. Because you don't need to build every single new library on your own. You could just go and use what's already there. And this is why you're able to just introduce Kotlin, for example, in Java project, piece by piece, like rewriting, maybe one, two files. And it's still working. Same would work for JavaScript. If you have a big JavaScript project and you want to use Kotlin, it will work that way. You will get a few Kotlin files, put in your project, modify, build script a little bit to support Kotlin, and you're done. You could write your apps and slowly, if you will like it, you'll transition to Kotlin. If you don't, you just remove the files. But I don't suggest that. Kotlin is very good. OK, so how many of you have the laptops? Any writing this demos? OK. OK, no worries. Yeah. The purpose of this talk was to build something simple using the Kotlin native. But I think we will not go this way now. And what I could do, I could show you some simple projects that will give you some perception of what the options you have using Kotlin native. I will use Cline IDE. It's very similar to IntelliJ or Android Studio. It built using the same IntelliJ platform and provide to you the same amount of cool shortcuts, auto-completion, refactoring that makes your life much easier as a developer. Here, I want to show you one of the samples. Actually, the few samples. First would be C URL. How many of you use C URL in your console? Nice. So basically, this is the C library that also sometimes distributed as a binary to allow you to execute some HTTP calls from your console. And this project is basically serial wrapped by Kotlin. It demonstrates how you could use existing C libraries from your Kotlin native application. The first thing to do is to download Cline. Of course, you could do it manually just using console tools. But yeah, so far I can't recommend that because documentation is pretty bad and in many places it's just missing. So it's pretty hard to figure out how to do it unless you want to read source codes or pistols. Yeah, really get into that a little bit. The basic idea is there is a tool that generates Kotlin APIs for your C libraries. This called Cintera. What we need to do first is we know the library. We want to have in our Kotlin native project and we go and create this .dev file. .dev file will describe the headers that we want to use in Kotlin application. Here, for example, we want to use serial headers. This is some more complex option for that that allow you to propose some path where the serial library currently plays and the platform that you want to use for this library. So after we did that, we could create CMake file. What we'll add in there? We'll add the Cintera structure here that will describe it. OK, now we have this .dev file and we want this .dev file really to be executed by Cintera tool and do new edges binding for us. We could apply some compiler options here as well. Then, using Conan C executable, we'll define our project. So for our definition, it's pretty simple. We have a name, we have our sources address, we just a directory name here, project c URL. We define the libraries that we'll use and again, some options for the compiler. After we did that, we will have this import libc URL that will actually lead us to all these automatically generated Kotlin bindings. So this is kind of headers, but for Kotlin and it translated from the C header. We could access any global variables defined here and any C functions. And if you have already experienced this Kotlin, these definitions would look super weird. This is because Kotlin, originally, it's very high level language. It doesn't allow you to work directly with your memory to interact with pointers, to cast value to the pointer and things like that. It's just prohibited for Java and even not possible in JavaScript. But here, what the main challenge was, it's to allow Kotlin to do this low level operations. And yeah, I hope someday there will be a lot of high level libraries for interaction with new libraries in Kotlin native, but it's not there yet. And if you will use Kotlin native, you need to prepare to know everything about C, which I don't. So yeah, but it doesn't stop me from giving you this stuff today. Yeah, the main trick here is to really find the piece of C code and try to convert it one-to-one in Kotlin. So this is not an example of conversion, but more an example of how you will create Kotlin APIs for some library written in C. Yeah, and here is the definition of these APIs. I will not go into that because for me, it doesn't make any sense. So if I want to use some high level library, I'll just use the Kotlin JVM. But yeah, here what's happening is that we create our APIs and we just call it here. And yeah, I'm not sure how this APIs is structured in CURL, but here we see pretty nice, very close to Java looking code that will allow us to use CURL. But if we will go to our next example, which is some simple socket server, we will see there is a lot of magic in here. First thing we will notice is what we really have to do in C is some function called initSockets. But to be honest, I can't call this a function. It's more like a procedure. But in Kotlin, there is no procedure, so everything you will call will be functions. We need to initSockets, which do some like black magic underneath some memory mapping and things like that. That will allow us then to use this pretty interesting, I could say, declaration called lambscope. For Kotlin JVM and for Kotlin JavaScript, there is automatic memory management and the garbage collection. It means that you don't need to care about how you allocate your memory and how you free memory allocated after that. All the objects will be garbage collected for you. If you don't need that, garbage collector will go and just read this memory. But for Kotlin native, since it's a really early stage, there is only one option available for now. And it's manual memory management. You will need to really go into depth of how the memory is managed in low-level libraries and really understand how this low-level libraries works, which again, I don't. So it's nice to have this lambscoped declaration that will automatically deallocate all allocated memory at the end of these curly braces. So yeah, pretty nice. And also, as you can see here, the code completion, it's a bit broken. This is my fault because I kind of created a project structure that's not really supported for the CLAN yet. Basically, this is a three separate project for a purpose of demonstration. But CLAN supports only one of them. Hopefully, I still could compile that. But as a side effect, it keep telling me that this code is not valid, which is not true. So in this example, what we'll do, we'll use default C APIs for the available for Linux and OS X to open the socket and start listening to that. And yeah, what we'll do, first we'll create a socket here with some magic flags, I could say. Then we will call some magic functions again. The thing is, what we care about is this bind, listen, and accept procedures we will call. So this sequence of calls telling us that, OK, this is the socket server. We will allocate the socket, and nobody else will be able to do that anymore. So we'll just keep listening to the messages. Then, again, using some magic calls that I will probably explain later, we'll just receive some message and send it back using this send calls. And yeah, we could actually see how it works right now. I already compiled this project, and fortunately, it compiles unlike the projects for iOS. I could launch my ECO server. And using the separate console, I could use telnet, yes, telnet console 2, that basically is pretty simple. What it does, it sends the message to the socket you specify. In our case, it's like 4,000. You could put here, hello, and we see the response. And also, here, we could see that we received this message. It took me a few hours to figure out how to convert row bytes into string in Kotlin native. But yeah, I think it worked. So the guys actually plan to release Kotlin native by the end of this year. And I hope they will cover many standard library functions that are already available for Kotlin JavaScript. But now, to do some simple operation that you used to do pretty easily in Java, in Kotlin native could be pretty hard. But it could be pretty easy as well. But yeah, most likely pretty hard. What we could also try to do, and is there any one who have a lot of experience with C? Oh, then you could help me. Because I can't launch this next application that's supposed to emulate telnet. For some reason, I'm getting a segmentation for every time I do something. And since I don't have much experience with C, for me it's pretty hard to figure out how to fix that. So yeah, what else I have here? If you're really interested to know really how it works, you could also refer this GitHub page with Kotlin native samples. There is a lot of them. And you could find all things that works for now including native duties in Kotlin, GTK bindings, HTML5, even OpenGL, and Windows 32 bindings. But to be able to compile that, you will need to spend a lot of time for now. So what I'm thinking about here now is that it would show you a little bit of cool thing that you could do in Kotlin. Possibly in future, it would be available in Kotlin native. To do that, you could actually use two things. There is a very good site called TryKotlin. TryKotlinLounge.org, yeah, this one. For those of you who don't want to install these IDs and just want to try Kotlin, this is a pretty good place to start. There is also a lot of examples that you could compile for JVM or the JavaScript. And yeah, you could do your first month of Kotlin only using this tool. But if you want some more advanced code completion and some fancy stuff, you could use RedoLA PrintLoop console here in IntelliJ IDE. Or if you have Android Studio, you could use Android Studio for that. It's also available in there. Here, you could experiment. I even use it on real projects because this is a very fast way of prototyping. And in this console, all the classes you use in your project is available. So for example here, let's see what we have in Kotlin application. Nothing much. But if we will add some library in there, we could just call it from this console. And let's say we want to create some function, like simple one. Enter the presentation mode, switch to Android. As you remember from the previous talk, Kotlin is very smart. And here, even in so basic example, we see very interesting things that not available for Java. Here, the type is automatically inferred. And even in IDE, it will just show you the hint for you to understand what's going on faster. Sometimes when you have inferred type and then you call some function and type again inferred and again inferred, it's pretty easy to lose the track of what object you have. But IDE, again, is very smart and it just helps you with that. Here, we see this is hello string. And the moment I change it to length, it said, OK, that's int right now. So it's pretty close to dynamic languages, but it's still statically typed and it still do a lot of work for you and catch tons of errors. Now we could just call this function. Yeah. Hello. What else we could do? How many of you are familiar with functional programming? So Kotlin, such a cool language is that it supports a lot of different paradigms. You could write your entire app using procedure style. You could have a high-level function. It will call another high-level function. And basically, that's it. In this case, we'll still call it function because in Kotlin, we only have function. But in reality, it would be like procedures. Also, you could use object-oriented programming. You could create objects, create properties for that, add some business logic, and yeah. This is what most of the people do. And what some of the people do, and now this, I could say, style of programming became more and more popular, it's to use functional programming in your apps. You could do it in Java as well, not so easy, but still a lot of functional concepts you still could implement and use. And it will work for all applications. Backend, Android, desktop, or even if you run Java on embedded systems, it will also work. So in Kotlin, there is a lot of tools that will allow you to do this functional programming easier. Let's say we have the same, like, A function. And what we could do is we could create some function B, for example. And this function B will accept the reference to the function A. So why we want to do that? This doesn't seem to make any sense. But more you use it, it starts to get more and more sense. Same as object-oriented programming. Once you started, you're like, oh, why do you need this object? Because I just could run some simple procedure, it will do the same thing. But here the interesting thing that we could do, for example, we want to call it 10 times. And this is another pretty cool Kotlin feature called ranges. So basically, if you want to get some numbers from 1 to 10, it's just a two-dots operator that will create a range for us. And then we could call this function we provide here like 10 times. Why is it working? Looks like some issue with this one. Now, when we have A and B functions, we could call B function and pass function A in there. Function A returns string. This is why static typing is good. In JavaScript, I could never even notice this error. OK, now we updated our B function and call A function again. We call B function and pass the A function there. So this is, I call it four dots. It's not very usable, right? Replace. This is four dots operator that basically translates our function to the function reference. And this is something you could do in Java as well. And this concept also available in JavaScript. And in Kotlin native, you could also do that, which you can't in C. So that's why you could think, OK, I will just get a C library, create the Kotlin wrapper around these APIs, and then use some fancy functional stuff with these nasty procedure calls. So and now, once we call it, and this is one more cool Kotlin feature that you could use like extension functions like let that will allow you to do some chain calls. In Java, if you want to pass some variable in one method and then pass the result of this method to another method, what do you usually do? For each line, you create a variable, assign the result of call to this variable, then do it again and again, maybe five, 10 times sometimes. And in Kotlin, there is a ways to avoid that. So basically, instead of doing something like this, print and pass their function result, I could call let and put print in there. And this is more natural because I execute function first, and only then I print it. But when you try to write this code in all object-oriented or procedure style, you should do it in reverse. So you basically need to know what you will do last and put this last operation first, and then you will be allowed to do that. And it doesn't really help to better understand your code. But in Kotlin, you could do the opposite. You could chain your calls in the way you intend to do it, not like you force by language. So here, we will call the function, get the result, and then we just print it. Yay, finally it works. So yeah, this is one of the reasons I really like Kotlin. And one of the reasons why I organized this Kotlin user group community here in Singapore is because I really believe that this language makes your life as a developer easier. And it allows you to do things that is more logical. And I could say, more natural for you, not like Java that forced you to do the only way possible. And in Kotlin, much more things is possible. And this is for a developer that makes your day-to-day job more interesting, since you find new and new ways of get better in how you do things. So we basically covered extension functions and what else, ranges, function references, things like that. Another pretty cool feature of Kotlin is, let me clear this, is sealed classes. And this is not the thing you will immediately start to use because it's cool. It's the thing that you will start to use when you feel that you need it. And sometimes something bad should happen that you will say, OK, I should be using that. So I prefer just to use sealed classes to not be cashed by this kind of person. So what is sealed classes? It's some concept that's pretty similar to enums, but it's much more powerful in a way that you could define much more things. Enums, it's very restricted. And many times I catch myself that, OK, in Java, in this case, it would be pretty good to use enums. But for some reason, I can't really do that because I need to extend some class or some other issue that I can't really fix because language not allow me to do that. In Kotlin, you could use sealed classes. And what it means, basically, you create the class and create a few other classes that inherit this class. But that's it. You restrict another pieces of code to be able to extend these classes. And this is pretty important for a few reasons. First, you see that, OK, all the inheritors of this class in the same file. And it could be only here. And I really could see what these classes intend to do. And second one, it allow you to do some additional checks on top of the static code analysis that done by compiler. I will show you what does it mean. Let's say we have some sealed class, let's say Action. And yeah, in Kotlin, that's it. This is the real class. In Java, it should be like Epsor class with single constructor. And that's it. In Kotlin, you don't even need to declare anything else. So the syntax is very simple and clean. Now, what we will do? We will create some classes that extend this action. Let's say, log in, and we will make them objects to make it more like enums. Let's say we have a simple application. And on the first page, you have log in and exit actions. And this is it. We create our sealed class. And now what we could do? We could make a processor for the sections. And as you could see here, the biggest difference from Java is the ordering. So you first write a name of your variable, and then you write the type of it. So this is done because of the type inference. And most of the time, you don't even need to write this part. So this is why it came last, to allow you to avoid it. Inside this process, what we'll actually do? We'll get some result variable. And this result variable we will get from when expression. So when expression is a very powerful thing, it's something similar to switch cases in Java. But when we use it with sealed class, it allows us to do a very interesting thing. Let's say, now we have an action we want to compare it with login. You don't have to write this like action.login, but inside this console, it's only work this way. This looks pretty similar to Java. But the interesting thing is, since we use this sealed class, in the moment, you will add new action here. Switch user, you will immediately see that this code is no longer valid. So what happened that we added more safety checks using Kotlin language features? In Java, to do something like this, you will have to use enums. But let's say action have some field. Immediately, all the actions here will need to implement this. We'll just put it empty one. And this behavior is no longer possible in enums, because enums can't extend existing classes. So for this, we could possibly say, OK, I could create enum and then pass to every enum some value in the constructor. But if we want to do something more complex, it would be not possible. But here, you're not limited by any limitations of the enums. And like using these actions, you would say, OK, login also have something like, here, the interesting thing I could do is that I could declare some of actions as classes and some of actions as objects. And it will still work. And all these type checks would be done as well, which, again, not really possible with enums. So here, I still have this error. It said, OK, you captured only two of three possible actions. You'll have to add one more. And why it's important, because especially on a big project where when you change some very basic stuff that used to build a lot of more complex things in a project, these kind of switches usually, in Java, have a default case or like some, yeah, basically that's it. Or if you use some if-else branches. And the moment you add something in some basic object, you will not have any errors. And the only way for you is just to search across all the project and fix all the things you find and hope that nobody else will raise some PR where this case will not be handled. And sealed classes allows you to avoid these kind of errors when you need to change something across all the project but you forgot to do it in a few places. Here, it would be the compilation error. So until you fix that possible errors, you will not be able to compile the project. And this is a pretty powerful thing. When you will use Kotlin, please use it. It will save you a lot of time. Another interesting feature of Kotlin is Lambda with receivers. So what does it mean? This concept is not available from Java or JavaScript but do available in a few other languages. And I will show you how you could use that. Let's say we have some string buffer. The code completion will not work, but believe me, it has this append function. And we could append many different things. And this is how I usually do it in Java. We just copy code somewhere in there. The moment we build that, we will get this string. But for me, it seems like a lot of duplicates code. How we could fix the Kotlin? And many of my colleagues would say, why do you need to fix that? I used to do it in Java for the last 15 years. What a point. But still in Kotlin, you could save some time and amount of operations you need to do by using Lambda with receivers. So how it will work? We will call some Kotlin function called apply. And what this function does, inside this function, we will basically, I could say, switch the context. And inside apply, now code behave like we are inside this builder class, which in Java it's not quite possible. But here it means that this is our builder. And we could avoid using this inside apply. What we will do, I'll just copy this code and just remove our builder.strengths. This is still red, but believe me, it will work. As you can see, result is the same. But what happened is we saved us a lot of boole plate, I could say, which doesn't seem like boole plate. But once you start, use Kotlin and start use functions like apply or we could replace it with run, for example, you will see that you could really save a lot of code. And it doesn't seem like a big win. But believe me, during the code review, you will appreciate that. Because here, now it's much simpler to understand. Example again is very simple, but sometimes we have something like, I don't know, in Android, for example, context.resources. What else? Let's say, getStream, yeah, it would be, obviously it would be getStream. And when you see this thing copied like few times, right? And inside some function like set, let's say, userInfo. And this is looks ugly. What many of developers will do, just extract this into some like variable, let's say like boole.resources. Give it some short name, so nobody else could figure it out later. And then replace this with resources. But it still looks ugly. It doesn't solve the main problem, right? So here, when we could eliminate even this, this is, again, much cleaner and much more enjoyable to see. OK, let me give you some bit more details about how it works. To make it work, what we need to do is actually to create our function. And here, we send this function, this set is a bit tricky. We could say, OK, we have StringBuilder. And after this dot, we put the type of lambda in there. So it basically means that this lambda will be executed in StringBuilder context, as we saw here, for example. And then we just create a StringBuilder. We'll just call function f with the StringBuilder as an argument. So even if we not have it here, we don't need to care about where it came from. This function will take care of it for us. Maybe you have some questions already, and I could figure out what to tell you about it. Yes? In the previous slide, you have the lambda. It was like, here, you mean? The CMake. Micro ESA intron, where is that macro now? This one? Yeah, this is, I could say, this is a cognitive extension for CMake, but I'm not sure if it sounds correct. But this is, like, from my limited understanding of how the native CMake works. So that means from the extant level, because I, for sure, I know those macro not the native CMake model. Yeah, yeah. So this is, like, Kotlin's CMake module, and I think it should have something to do with that. But probably all this definition is somewhere here. Yeah, I could be wrong, but it seems like that. So basically, here, if you're using Ciline and you create a new project and choose Kotlin, for example, with the Hello World, it will create all this structure for you, including Kotlin's CMake module, which I guess provides all these extensions to work with Kotlin native. Only C, probably, is possible, not with C++. Basically, with C++, this is a good question. Probably not yet, but if C++ library exposes C like APIs, it would be available. So I guess it depends on the type of header you provide. If this is a C++ library and C header, you will be able to get all this function. So basically, for Kotlin, it doesn't care. What happens to the standard library that Kotlin has? It's not available. It's available, but not fully. For example, if I'll try to do... Yeah, I could think about any particular example, but yeah, Kotlin native library is quite different from Kotlin's standard library for JavaScript and JVM. And the truth is that all these three libraries, it's quite different because, let's say, Kotlin standard library for JVM rely heavily on existing JavaScript APIs. And the Kotlin JavaScript library rely on existing JVM APIs and Kotlin JavaScript rely on JavaScript APIs. And sometimes it's pretty similar, and in this case, APIs for Kotlin standard library would be same, but in case API is very different, it would be, again, a different API for Kotlin standard library, yeah. But still, I guess it should be already at least a few libraries available that will unify this behavior, and you could use some functions that you built to extend these standard libraries to allow you to use the same APIs for the platforms. But from my experience, standard library for Kotlin native, it's the smallest one. And another difficulty, at least for me, since Kotlin native built to interrupt the C for every platform, you will be having like different, I could say, system libraries, right? Because for Windows, it would be like VIN32 and for OSX and Linux, it would be OSX. So APIs would be completely different. And so far, since it's very early stage, there is no, like, no libraries that will unify this. And I don't think it's even possible. As an example, if I had a Kotlin project in which I was using some extensions for, let's say, array-plarting or something, Kotlin standard library, and I then targeted the JS run, it's likely it'll not work because some of them are not there. Most likely it will work, because if your extensions using only standard library functions that available on both platforms, I mean, like functions and the classes, if it available on both platforms, your extensions will be, again, available on both platforms as well. Is that an express motivation for the JetBrains team to have the standard library on all platforms? Yeah, yeah. As far as I know, they're working pretty hard to really extend this standard library to the point where it would be very, very close on every platform they support it. Yes? I wanted to ask, like, a date around the Kotlin development. But the thing is, I can only write the business logic. You said it's cross-platform, right? So right now I can only write the business logic in Kotlin. For the UI part, I still have to write different set of codes. Yes, yes. Do you think there's a possibility that the UI part will be common as well? Let's see what we want. Yeah, yeah, it's actually possible. Since Kotlin native already have pretty good support of OpenGL, you could build, let's say, your own library for UI, and then it would be, like, cross-platform across Java, JavaScript, and native, since all the platforms now support OpenGL. I mean, I was aiming at Swift, because, like, I guess, they were Swift, yeah. For Swift, it would be, I could say, pretty hard to achieve, because you will have to find, if you have to first, like, design the same API to be able to handle, like, every cases of particular view, like, for example, you have a button.