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

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.

Related

How to switch between multiple versions of Kotlin?

I need to provide maintenance support for the "legacy" mobile App, while also providing enhanced feature support to the "next major version" of this mobile App. To do it efficiently, I need to be able to switch between 1.3.x and 1.4.x of the Kotlin compiler. Everything that I am reading, implies that Kotlin only moves forward, so I hesitate to upgrade my version of Kotlin in Android Studio to get 1.4.x plugin installed without the confidence that I can switch back to 1.3.x.
It looks like a simple change in the Gradle build scripts should work, but it is not clear that changing the version changes all of the toolset, or simply tries to be backward compatible from a future-looking configuration.
You can update the Android Studio plugin safely - it should be backward compatible with the older versions of Kotlin.
If you want to change the compiler version (for using new language features), you should update the version in the Gradle script - you can change it whenever you want, the older versions of Kotlin libs and compiler are still available in the repositories.
I recommend you to always update Android Studio plugin to the latest version, so you have full Kotlin support in your IDE for all versions of the Kotlin compiler.

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

Where to find (install) Kotlin cinterop tool on Mac

I would like to try to build Kotlin/Native project with dependencies on some library.
As documentation explains, I need to create def file (which I was already created) and run cinterop tool.
However, I wasn't able to find this tool on my Mac and curious how this could be installed.
Can you please give me some advice?
I strongly advise you to use Gradle + Kotlin MPP plugin. Not only it will provide cinterop support, but it will ease further development, testing, and multiplatform support. It works on any OS, of course.
If you need an example, here is the official one for the cURL library: https://github.com/JetBrains/kotlin-native/blob/master/samples/libcurl/build.gradle.kts. Note the cinterops block under compilations["main"].
The nice thing about Kotlin MPP plugin is that it actually allows you to play with the Kotlin/Native tools directly. It will download the tools specifically for your platform automatically on the first run and place them in ~/.konan directory. So if you really want to use cinterop tool from CLI you'll be able to find it there: ~/.konan/kotlin-native-macos-1.3.61/bin/cinterop. klib and kotlinc are there as well.

OSGI aware IDE at development time

I'm starting development using OSGi but when one of my concerns is about the lack of support at development time, meaning that commonly IDEs (started using Intellij IDEA) don't use OSGi for class discovery but classpath search IDE managed (I'm in search for one that uses OSGi instead).
The main concern here is to prevent classpath issues at execution time by suing the same OSGi mechanisms at development time.
Does any IDE work this way ?
update: added link to blog post with my experience with IDEA
OSGi is a runtime technology, therefore there is no such thing as an OSGi mechanism at build time. Also bear in mind that ultimately all Java code must be compiled by a Java compiler, usually javac. The javac compiler does not use package dependencies like Import-Package, it always uses JARs or directories on the classpath.
Having said that, Bndtools uses package filtering at build time, based on the exported and private packages of the dependencies. This is a special feature of Eclipse and it does not work when you compile outside of the IDE, e.g. with Ant or Maven. However it may still be useful because if you try to use a non-exported package from another bundle you will get a problem marker with a red X in the Eclipse IDE.

Using Maven as build tool for Lua programs

I need a build tool for compiling,testing, reporting and the deployment of Lua programs.
I chose Maven 2 because of our Polarion version supports it.
Unfortunately, I couldn't find any Maven plugins/archetypes for Lua.
As I am a newbie in Maven I want to know whether it is difficult to write a customized Lua plugin for Maven.
You can hook up the maven-compiler-plugin with any plexus compiler (reference here).
So I guess the standard way would be to write a plexus wrapper for the lua compiler using the Plexus Compiler API