typestar

The program shape in Kotlin

The smallest Kotlin program: no class, no package line, just main.

// A Kotlin file needs no ceremony: main is the whole program.
fun main() {
    val hut = "Larkspur Hut"
    println("Lights on at $hut")
    println("Beds free: ${18 - 11}")
}

How it works

  1. A top-level fun main() is the whole entry point.
  2. val binds the hut's name once; println writes a line.
  3. $hut and ${18 - 11} splice values and expressions into strings.

Keywords and builtins used here

The run, in numbers

Lines
6
Characters to type
164
Tokens
34
Three-star pace
75 tpm

At the three-star pace of 75 tokens a minute, this run takes about 27 seconds.

Type this snippet

Step 1 of 3 in Values, step 1 of 27 in Language basics.

Next →

The program shape in other languages