Skip to the content ForoHackers
Log inJoin

Kotlin: start here

Kotlin
#559 · Ophuscado · · Report

Kotlin is a modern, statically typed language that is concise and safe, and runs on the JVM, in JavaScript and as native code. It interoperates fully with Java, so it can be adopted one file at a time. It is the main language of Android development and is widely used for back-end services and shared code across platforms.

Key concepts

  • Null safety: the type system separates values that may be null from those that cannot, and forces you to handle the first.
  • Concise classes: data classes, properties and default arguments remove boilerplate.
  • Immutability by default: read-only values and collections are the encouraged style.
  • Functions as values: lambdas, extension functions and higher-order functions give a light functional style.
  • Coroutines: structured concurrency written like sequential code.
  • Java interoperability: call Java libraries directly and be called from Java.

Vocabulary

  • Extension function: adds a function to an existing type without changing it.
  • Sealed class: a closed set of subtypes, ideal with exhaustive when expressions.
  • Smart cast: the compiler narrows a type after you check it.
  • Multiplatform: sharing Kotlin code between several targets.

What to study, in order

  1. Basic syntax, val and var, functions and control flow, with a small program.
  2. Null safety, data classes and collections; convert a Java class to Kotlin.
  3. Lambdas, extension functions and sealed classes with when.
  4. Coroutines: launching, suspending, cancelling and handling errors.
  5. A project in your target, such as an Android app or a server, with tests.

Related tags

#java #android #functional-programming #cross-platform

Log in or join to reply.