Dev Watch

Blog archive

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).

Kotlin Gains in Popularity
[Click on image for larger view.] Kotlin Gains in Popularity (source: Stack Overflow Trends)

Here's a look at the other two Kotlin offerings:

Kotlin Language
This extension comes from developer Mathias Fröhlich, providing Kotlin language support for VS Code -- basically a syntax highlighter for the Kotlin language. Fröhlich credits the open source Kotlin Sublime Text 2 Package, so his extension is likely based on that.

As of this writing, the extension has been installed in VS Code 7,091 times. It hasn't been reviewed by users.

On the project's GitHub site, it has garnered 23 stars, with 13 commits coming from three contributors. It was last updated in November.

Code Runner
Coming from developer Jun Han, this tool isn't Kotlin-specific -- rather, it lets VS Code users run code snippets or code files coming in 35 different programming languages. Kotlin is the latest addition to that extensive list.

Kotlin in Code Runner
[Click on image for larger animated GIF.] Kotlin in Code Runner (source: Jun Han)

Code Runner provides the following features:

  • Run code file of current active Text Editor
  • Run selected code snippet in Text Editor
  • Run custom command
  • Stop code running
  • View output in Output Window
  • Set default language to run
  • Select language to run
  • Support REPL by running code in Integrated Terminal

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 Resources
So 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."

Til next time: Happy Kotlining!

Posted by David Ramel on 06/01/2017 at 1:46 PM


Featured

Upcoming Events

AppTrends

Sign up for our newsletter.

I agree to this site's Privacy Policy.