SyntaxStudy
Sign Up
Kotlin Beginner 1 min read

What Is Kotlin?

Kotlin is a statically typed, cross-platform programming language developed by JetBrains and officially supported by Google for Android development. It runs on the JVM, can be compiled to JavaScript, and supports native compilation via Kotlin/Native, making it a truly multiplatform language. Kotlin was designed to fix many of Java's pain points while remaining fully interoperable with existing Java code. It reduces boilerplate, enforces null safety at the type-system level, and supports both object-oriented and functional programming paradigms. Since 2017 Google has promoted Kotlin as the preferred language for Android, and today the majority of new Android applications are written in Kotlin. Its concise syntax and expressive type system make it equally popular for backend development with frameworks such as Ktor and Spring Boot.
Example
// Hello World in Kotlin
fun main() {
    println("Hello, Kotlin!")
}

// Top-level functions, no class wrapper needed
fun greet(name: String): String {
    return "Hello, $name!"
}

// Single-expression function shorthand
fun square(x: Int) = x * x

// String templates with expressions
fun describe(n: Int): String {
    return "The square of $n is ${square(n)}"
}

fun main2() {
    val message = greet("World")
    println(message)
    println(describe(5))

    // Type inference
    val language = "Kotlin"   // inferred as String
    var version = 2.0         // inferred as Double
    version += 0.1

    println("$language $version")
}