Dev Watch

Programming with Kotlin in Visual Studio Code

Kotlin is all the rage now that it has been deemed a first-class programming language for developing Android apps.

Actually, it's been raging all on its own for a while now, as evidenced by the Stack Overflow Trends chart below. That empirical evidence is substantiated by my own subjective experience -- in other words, Kotlin has been increasingly prominent in my daily deluge of news releases and e-mails from PR types.

As I occasionally dabble in Android development (using React Native), for which Visual Studio Code is my favorite editor, I decided to investigate that tool's support for Kotlin. There isn't much.

Support for programming languages in VS Code is typically provided through extensions, which can be found in the Visual Studio Code Marketplace. While searching there -- under the Languages section -- for Java, for example, I found 77 results. For Python, I found 10. For Kotlin, I found three (one of which is just a JavaScript ES6 template literal editor that happens to have a Kotlin tag).

Code Runner's new support for Kotlin was announced in a blog post last week on the Microsoft developer site.

"In recent Google I/O 2017, Kotlin has been announced as the [actually, just "a"] official development language of Android by Google," says the post authored by "formulahendry". "And now, it’s time to support Kotlin in Code Runner!

"Kotlin tools will be included with Android Studio 3.0 by default, and JetBrains and Google are pledging to support the language going forward. Kotlin as a language has a lot of similarities to Java in structure. Moreover, Kotlin adds a lot of nice-to-have features, a much cleaner syntax, ideas from functional programming, and other enhancements over Java. Come to VS Code and have a try!"

The Code Runner extension has been installed 432,539 times and has an average rating of 4.6/5 from 44 reviewers.

The project's GitHub site shows 126 stars, 61 commits, 39 releases and nine contributors. The last commit was 13 days ago.

More ResourcesSo there you have it. While Kotlin doesn't have as much VS Code support as some other popular languages, you can install extensions to highlight Kotlin syntax and run Kotlin code snippets or files upon command.

If it's any consolation, searching for Kotlin in the full-fledged Visual Studio IDE section of the marketplace brought up 0 results.

So it looks like Android development with Kotlin might be better left to Google's default IDE, Android Studio. Luckily, there are plenty of resources to consult for Kotlin programming with that tool. Here's a list:

BTW, for non-Kotlin Android development in VS Code, there's an "Android for VS Code" extension. Its description says: "This is a preview version of the Android for VS Code Extension. The extension allows developers to install, launch and debug Android Apps from within the VS Code environment."