Learning Kotlin: Programming with Visual Studio Code

Joseph Maurer
3 min readApr 20, 2021
Source: Artem Diashkin

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!

The IDE

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!

--

--