We can compile it and then run, we have REPL for it and we can even run it as script.
.kt
vs .kts
.kts
.Expressions over Statements
Kotlin is a JVM language, and so the compiler will emit Java bytecode. Because of this, of course, Kotlin code can call Java code, and vice versa! Therefore, you need to have the Java JDK installed on your machine.
When we compiled a kotlin program and produce the JAR, we instruct the compiler to bundle in the Kotlin runtime.
Kotlin comes with its own standard class library (Kotlin runtime
), which is different from the Java library. As a result, you need to merge it into the resulting JAR, or provide it in the classpath.
The runtime footprint is very small one can't argue otherwise.
Kotlin code is usually defined in packages. Package specification is optional: If you don't specify a package in a source file, its content goes to the default package.
Kotlin has powerful type inference. While you can explicitly declare the type of a variable, you'll usually let the compiler do the work by inferring it.
Val vs Var
You're free to choose when you initialize a variable, however, it must be initialized before the first read.
Kotlin does not enforce immutability, though it is recommended.