Kotlin standalone compiler manual installation - kotlin

Looking at https://github.com/JetBrains/kotlin/releases/tag/v1.3.0, there is a generic multi-platform zip file (kotlin-compiler-1.3.0.zip) and some platform-specific ones (e.g. kotlin-compiler-1.3.0-release-windows-x64.zip). Looking inside the zip files, the differences seem to be that the platform-specific installations contain some native executables (e.g. .dll or .so files) and uses its own pre-built JRE, whereas the multiplatform version seems to be pure Java.
Is this the only difference, or do the platform-specific installations contain some extra features over and above the pure Java version?
Would it be safer to use the pure Java version, since my Java 1.8u192 release is later than the one Kotlin 1.3 was built with?

The platform-specific installations are AOT-compiled using Excelsior JET. That's the only difference; there are no extra platform-specific features.

Related

What does "common" mean in kotlin documentation?

In kotlin standard library documentation i can see the following filters:
As far as i can gather, JVM means that internals of a package can be compiled into byte code, JS into javaScript and Native into binaries. But what does "Common" mean ?
Common means available for all platforms. It is an API that you can use directly in platform independent code in Kotlin Multiplatform projects.
Kotlin Multiplatform allows you to write common Kotlin code for multiple different platforms. For example, you could have a project with an Android app (using Kotlin/JVM for native Android applications) and a web interface (using Kotlin/JS). Then, you could share code between both subprojects.
As you have guessed correctly, JVM means it is available using Kotlin/JVM (compiling to Java bytecode).
If it is marked with JS, it is available for Kotlin/JS which transpiles the Kotlin code to JavaScript.
Finally, Native means it is available when using Kotlin/Native. This is different from compiling with native-image, which compiles JVM bytecode to native executables. For that, you would still use Kotlin/JVM.
If you write code in "common", then it can be compiled into any of the other targets, so you can share Kotlin code amongst the different platforms you are targeting. You can read more in the documentation.

Kotlin bytecode buildable with Java

Is it possible to produce the same bytecode that the Kotlin JVM compiler produces using pure Java source files? If it makes a difference depending on the platform, I'm asking for the major desktop operating systems, not Android.

Can we develop desktop applications in kotlin?

I want to develop Desktop and Android applications. And I want to learn kotlin for this. Kotlin is mostly used for developing Android applications but I want to know that can we develop desktop applications in kotlin?
Yes, you can. Technically any program you can write in Java can also be written in Kotlin*. Of course it's even better when using frameworks that were specially tailored for Kotlin.
There are frameworks like TornadoFX built on top of JavaFX to build desktop UIs.
More recently, Compose has been generalized for Desktop apps (initially JetPack Compose for Android).
*More specifically, Kotlin/JVM compiles to Java bytecode, so you can use Kotlin to target any environment running a JVM that interprets this bytecode (provided the target bytecode version is at most that of the JVM, like in Java).
As pointed out by #Tenfour04, GWT is not in this category because it directly works on the Java source code, not bytecode.

Which Kotlin download do I need?

I'm getting started with Kotlin, and on the downloads page I see two different possibilities that look relevant for me:
kotlin-compiler
kotlin-native-windows
What's the difference? In what case would I need one or the other?
Most probably you won't use CLI to compile, build and run Kotlin projects a lot. Well, maybe you'll need a standalone compiler a few times compiling "Hello world" when starting with this language. BTW, you can use https://try.kotlinlang.org to compile simple programs and play with the language without local installations.
But as you proceed, it won't be enough. Most Kotlin projects today use either Gradle or Maven. Gradle scripts could be written in Kotlin themselves. I recommend you taking this extra step and use build tools instead of standalone compiler, as it will simplify a lot if things in future. IntelliJ IDEA, the most popular IDE for Kotlin made by JetBrains, the company behind Kotlin, allows you to create Gralde-based Kotlin projects in a few clicks.
Kotlin is a multi-platform language. It can be compiled to produce binaries compatible either with:
Java
JavaScript
A native platform (Windows, Linux, iOS, etc.)
Which compiler you should choose depends on your needs. If you don't need to make your code operate with a C library or a specific OS tool, I'd recommend the kotlin-compiler, so you'll get an app executable through Java, which (at least for now) produce more optimized programs, and also easily portable (install a jre on target computer and you're ready to execute your Kotlin program). Plus, you'll be able to use any Java lib you need in your kotlin program.
Note : Official documentation contains guides to get started:
Command line compiler for JVM
Command line compiler for native executables

Pros and Cons with installing Kotlin standalone compiler instead of using IntelliJ Kotlin plugin?

i understand that i can use Kotlin Plugin comes with IntelliJ but i can also install Kotlin standalone compiler. Is there any pros/cons using standalone vs IntelliJ own integrated?
I'd say that:
Any real Kotlin project (including projects in IntelliJ) should use a build system such as Gradle or Maven.
Enabling Kotlin support in a Gradle/Maven project will automatically download the correct compiler (and switch it when you update the Kotlin version in the config file) and not care about whether you have a stand-alone version installed.
Any other Kotlin tool will likely be integrated with them as well.
So the standalone compiler is pretty much only useful when you want to try something quickly outside any project, but then https://play.kotlinlang.org/ or https://try.kotlinlang.org/ can work as well; and again let you switch between Kotlin versions simpler than a manually installed compiler.
Running Kotlin scripts may be the only case where I would use the stand-alone compiler.
Not much, but having own install have few advantages, but probably not needed by most people on their machines:
You don't need intellij, so you can use that compiler in other IDE or just for other applications
You can use different version of compiler than the one from plugin.
But in most cases integrated one is all you need.