DEV Community

Cover image for Learning Kotlin: Programming with Visual Studio Code
Joseph Maurer
Joseph Maurer

Posted on • Originally published at josephamaurer.Medium

Learning Kotlin: Programming with Visual Studio Code

Kotlin has been a pretty steadily growing programming language over the last few years and yet I have never gotten a chance to use the language. Most of the work I do is in c# which doesn’t seem to be that different from Kotlin so I’m interested to see how long it will take me to get familiar with the language. I figured I would document how I go about getting started!


For those following along, there is official documentation that seems to be fairly straightforward. Maybe the IntelliJ IDEA is amazing, but I honestly hate having to download a full IDE just to try out a language. So instead of following that, I’m going to be using Visual studio code!

Source: Visual Studio

To get started, you are going to need to install the compiler. To do this, go ahead and run the following commands via the command line via Homebrew:

VS Extensions

In order to support programming languages in VS Code, you are going to need to install an extension from the Visual Studio Marketplace. The extension that we need to download is called “Kotlin Language” by Mathias Fröhlich. See this screenshot below:

If you don’t already, Code Runner is another extension that you will need to have in order to execute Kotlin code in VS Code. Using the same process as before, look for “Code Runner” in the extension store. This extension is really useful for being able to execute a bunch of different code source.

“Run code snippet or code file for multiple languages: C, C++, Java, JavaScript, PHP, Python, Perl, Perl 6, Ruby, Go, Lua, Groovy, PowerShell, BAT/CMD, BASH/SH, F# Script, F# (.NET Core), C# Script, C# (.NET Core), VBScript, TypeScript, CoffeeScript, Scala, Swift, Julia, Crystal, OCaml Script, R, AppleScript, Elixir, Visual Basic .NET, Clojure, Haxe, Objective-C, Rust, Racket, Scheme, AutoHotkey, AutoIt, Kotlin, Dart, Free Pascal, Haskell, Nim, D, Lisp, Kit, V, SCSS, Sass, CUDA, Less, Fortran, and custom command”

Once you have everything downloaded, create a new file called “hello.kt” and add the following lines:

Upon saving the file, right click and select: “Run Code”

After compiling, you should see an output window appear. Here’s what mine looked like!

Congratulations, you’ve just run your first Kotlin code! Next post, we’ll get into the fun stuff but for now, we have everything ready to go 😎

Thank you for reading this far. If you enjoyed this post, please share, comment, and press that 👏 !

Follow me on Twitter and Medium if you’re interested in more in-depth and informative write-ups like these in the future!

Top comments (10)

mwrpwr profile image
Joseph Maurer • Edited

Jetbrains is known for their code analysis tools that help you code fast, but so far I've honestly been enjoying the simplistic approach that VS Code offers. If you are doing any production Kotlin work, I agree that the IDE would be valuable, but it seems superfluous for simply trying to learn the syntax and language features. VS Code can do a lot of the code completion stuff.

As I get further into Kotlin maybe I'll do a post about the advantages/disadvantages of using the IDE over using VS Code! Thanks for the idea 👍🏻

ozzythegiant profile image
Oziel Perez

Any specifics on what one would miss out on? Just trying to connect the dots, as I would think all that's needed for Kotlin development is the LSP, a viable extension for VS Code, good debugger, and either Maven or Gradle, along with their extensions, for dependency management and task running. For back end stuff, I would think that's all you need. For Android, there's no escaping Android Studio unless you drop it altogether for a different language.

igorlino profile image
Igor Lino

Kotlin was created and is driven and maintained by JetBrains, therefore JetBrains IntelliJ will obviously have the best Kotlin support. Its the same plate.

Unfortunately this brings a conflict-of-interest. Why would other editors implement plugins for Kotlin?

Looking at the github stars of the Visual Studio Code plugin for kotlin language support:
you see only 164 stars, updated in Feb 2020.
Definitively seems a bit dead.

If JetBrains would take care of creating a production ready VisualStudioCode plugin to support for Kotlin, which they won't as they want to promote their own paid IDE, then there would not be conflict of interest.

It seems to me a bit of vendor lock-in.

That being said, I would avoid Kotlin altogether till there is no conflict of interest and as long as i'm not bound to a JVM stack.

Thread Thread
ozzythegiant profile image
Oziel Perez

Agreed. I have taken the same stance for Swift, as Apple will never port their SDKs to be available outside of MacOS. A real shame too because I love both Kotlin and Swift, but because, even though they are open source languages, they are mostly bound to their original platforms, I'm not gonna waste my time trying to switching between tools.... maybe Dart and Flutter will finally break such old ways.

ozzythegiant profile image
Oziel Perez

Yeah I don't expect JetBrains to provide the tools, but I do think the open source community can fill that gap.

turry profile image

Fleet IDE :D