Saturday, May 18, 2019

Getting Started With Kotlin

On the Kotlin download page, the native and experimental downloads versions of Kotlin for Windows, Mac and Unix do not work with the JVM. The JVM compatible version is simply "kotlin-compiler-1.3.31.zip".



Kotlin can be installed using Choco on Windows, Homebrew on Mac and wget on Unix. I chose to download it and so, after extracting the files, I had to add the kotlin/bin folder to the PATH on my machine. Java is, of course, prerequisite.

From the command line, entering kotlinc starts the REPL.

C:\>kotlinc
Welcome to Kotlin version 1.3.31 (JRE 1.8.0_191-b12)
Type :help for help, :quit for quit
>>> fun greet(name: String, greeting: String = "Howdy"): String = "\n$greeting $name"
fun greet(name: String, greeting: String = "Howdy")>>>
>>> println(greet("Greg"))
println(greet("Greg"))
Howdy Greg
>>> println(greet("Sue", "Bonjour"))
println(greet("Sue", "Bonjour"))
Bonjour Sue
>>> :quit

C:\>