Questions about Kotlin Native

I read online about Kotlin Native. Intriguing! It doesn’t require the Java Runtime
Environment!

I read online that Kotlin Native can be compiled to Android & iOS apps. I also found out that one can create Mac, Windows & Linux apps.

I have a Mac. Can I create an app on my Mac that will run on Windows 11? How about older versions of Windows?

You can create application for Windows 10 and probably Windows 7 as well. But if you want create a native app for better performance, you should not. Because performance will not be better.

2 Likes

That makes sense. I don’t want to learn Java because it is so verbose. Scala has weird syntax.

I don’t want to have both a Windows PC & a Mac.

I’m intrigued that Kotlin Native doesn’t require the Java Runtime Environment in order to run.

Why do you try to avoid JRE?

2 Likes

I have a friend who has Windows 10 on his laptop. He probably has Java installed but he may not. If I create a Java app & he doesn’t have Java installed, he won’t be able to run the app. But, if I use Kotlin Native & can create a Windows app then he can run the app without having Java installed. Sure, the app that I create probably won’t run as efficiently as a native Windows app.

That’s why Kotlin Native intrigues me so much.

I don’t want to own both a Windows laptop & a Mac.

Do not use Kotlin Native

  • it is very slow compared to JRE version
  • it has almost zero standard libraries, you have to write everything on your own
  • it doesn’t have debugger on windows
1 Like

I do not recommend using Kotlin Native either, but your points are not quite valid.

  • The throughput is lower than on JVM in most cases, but it is comparable. Peak performance is the same. Though native requires more manual optimizations. As always.
  • Kotlin standard library is enough for most things. Also, the multiplatform ecosystem is already huge. CInterop allows using any C libraries as well.
  • I have not checked, but I do not see, why debugging on windows should not work. Bothe lldb and gdb could run under windows.
1 Like

“Peak performance is the same.”
Definitely not. On medium memory intensive tasks it is slower like 500%.

“Kotlin standard library is enough for most things.”
Definitely not. Well, maybe for school things, but not for professional stuff. (eg. no file system support, no json/xml processing). And CInterop is sooo much fun to use, compared to jre library with all stuff ready to use.

“I have not checked”
If you don’t have knowledge on the subject, don’t talk about the subject.

@TC @darksnake just out of curiosity, why wouldn’t you recommend using Kotlin Native? I guess because of it’s early stage? Or are there any major red flags?

I am asking because I am using Kotlin Native since a few months and had nothing but a pleasant experience so far, CInterop works really great and it didn’t felt that slow. The lacking of 3rd party libraries is of course a bummer, but regarding the early stage I didn’t expect a huge set of libraries.

I would like to see those tests. Also, which memory model do you use?

I agree that JVM is much more convenient. But compared to, say, C++ Kotlin-Native provides a superb experience.

The documentation refers to the use of lldb. Can you confirm it does not work for windows? Or you are talking only about MSVC?

I do not recommend using Kotlin-Native on the desktop because it does not solve any problems Kotlin-JVM does not solve (save for slow start). And Kotlin-JVM is muuuch better. So it is just a comparison of a nice tool with a great tool.

It seems to me that you don’t recommend Kotlin Native but JRE instead. I get the impression that Kotlin Native has more disadvantages than advantages - slow, not enough libraries.

How does Kotlin Native run without the JRE?

Isn’t it possible to create a Java executable that will run without the JRE?

I don’t want to learn Java. It is too verbose. Scala has a strange syntax. Groovy’s syntax is similar to Java. Jython isn’t up to date. That’s why Kotlin intrigues me. The syntax is simple.

I didn’t expect to get such a response to my questions.

Kotlin Native compiles to native OS executables, not JVM bytecode. This is why it is Native.

Kotlin compiler itself uses JDK, so you need JDK to compile it. But not to run.

The JVM is a great developer experience and is easier than many other platforms. Trying to avoid it, especially in the name of an easier development experience, will be challenging.

If you’re new to programming, start with tutorials and write one program at a time. At this point, you do not need to optimize which tool does what compiling until after you’ve learned more and written several programs.

Yes, you can create standalone executables of JVM apps in several different ways besides a runnable Jar. Your real question of “will I be able to easily share and run my code with Windows?” is a clear “yes”. JVM programs are portable, easy to share, and have multiple packaging options that aren’t runnable jars (once you get to that point).

1 Like