Mastodon Icon GitHub Icon LinkedIn Icon RSS Icon

Kotlin Development in VS Code

Kotlin is a really sweet language. It is the perfect thing in between a “super-powerful and but difficult language” like Rust or Modern C++, and a “super-easy but that seems to be designed in the 80s” like Go. With the upcoming release on Kotlin Native, then, you can even ditch the JVM!

However, while IntelliJ is a great IDE, often I do not like to rely on big IDEs — especially when VSCode works perfectly well for 90% of my use cases. Therefore, it is time to see if and how I can use Kotlin in VS Code (and see what is missing).

Install Kotlin “Standalone”

Obviously, the first step is to install the stand-alone version of the Kotlin compiler. Instructions are here but if you do not want to spend extra clicks the basic instructions are:

  • If you are using MacOS and Homebrew, then just run brew install kotlin.
  • If you are using Ubuntu, just run sudo snap install --classic kotlin.
  • Otherwise, just download the zip and unpack it whenever you want (and add the folder to PATH).

For projects, both Gradle and Maven are compatible with Kotlin. However, I assumed that you have them installed for your standard JDK experience.

Kotlin Language Support in VSCode

The absolutely required extension is Kotlin Language. This extension adds syntax coloring, code folding and a very basic support to the language. It is very basic but it works well.

Another plugin is called just Kotlin. It is still in “preview” but it seems to work fine. It is more “powerful” than the previous one: it also adds a basic IntelliSense support (code completion, signature helps, _go to _ definition and more).

Another highly suggested extension is Code Runner. This is not a Kotlin-specific extension but it does the job of compiling and running the application with a simple code combination.

However, I do not really get it. At the moment Kotlin support is very basic and it is nothing that this line does not do:

kotlinc foo.kt -include-runtime -d foo.jar && java -jar foo.jar

So, instead, if you do not want this extension just for Kotlin, you can use the integrated task runner. Create a task.json file and write this in it:

    // See https://go.microsoft.com/fwlink/?LinkId=733558
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
            "label": "build",
            "type": "shell",
            "command": "kotlinc test.kt -include-runtime -d foo.jar && java -jar foo.jar"

If your Kotlin project is a Maven project, then there is already a preset in VSCode. Go with it.

Other Useful Extension

In the VSCode Extension Store there is also a debugger called — without much imagination — Kotlin Debugger. I do not use it but, from what I have seen, it works fine.

Conclusions and State of the Environment Evaluation

My impression is that Kotlin support in VSCode is evolving, it is fine, but it is not there yet. The experience is worse than with IntelliJ (of course, you may say) but it is also a bit worse than VSCode experience with other languages.

I’ll come back to this in the future! VSCode is my editor of choice and I will not give up on it so easy. :)

comments powered by Disqus