Chapter 1. Installing and Running Kotlin
The recipes in this chapter help you get up and running with the Kotlin compiler, both from the command line and using an integrated development environment (IDE).
1.1 Running Kotlin Without a Local Compiler
Problem
You want to try out Kotlin without a local installation, or run it on a machine that does not support it (for example, a Chromebook).
Solution
Use the Kotlin Playground, an online sandbox for exploring Kotlin.
Discussion
The Kotlin Playground provides an easy way to experiment with Kotlin, explore features you haven’t used, or simply run Kotlin on systems that don’t have an installed compiler. It gives you access to the latest version of the compiler, along with a web-based editor that allows you to add code without installing Kotlin locally.
Figure 1-1 is a snapshot of the browser page.
Figure 1-1. The Kotlin Playground home page
Just type in your own code and click the Play button to execute it. The Settings button (the gear icon) allows you to change Kotlin versions, decide which platform to run on (JVM, JS, Canvas, or JUnit), or add program arguments.
Note
As of Kotlin 1.3, the Kotlin function main can be defined without parameters.
The Examples section contains an extensive set of sample programs, organized by topic, that can be executed using an embedded block in a browser. Figure 1-2 shows the “Hello world” program ...