2017 - Google announced first-class support for Kotlin on Android. • 2017 - Sharing code between JVM and JavaScript platforms • 2018 - Coroutines support for asynchronous programming. • 2019 - Google announced that the Kotlin programming language is now its preferred language for Android app developers. • 2020 - Support for Apple's platforms.
(check) { operation() } } onlyIf(shouldPrint) { println(“Hello, Kotlin”) } // which will be inlined to this if (shouldPrint) { // no need to create lambda println(“Hello, Kotlin”) }
class Failure(val error: Error): NetworkResult() } // one observer for success and failure fun parse(data: NetworkResult){ when(data) { is Success -> showResult(data.result) // smart cast to Success is Failure -> showError(data.error) // smart cast to Failure } }
with Kotlin"} } body { h1 {+"XML encoding with Kotlin"} p {+"this format can be used as an alternative markup to XML"} a(href = "http://kotlinlang.org") {+"Kotlin"} p {+"some text"} p { for (arg in args) +arg } } }
HTML() html.init() return html } fun head(init: Head.() -> Unit) : Head { val head = Head() head.init() children.add(head) return head } html { head { ... } body { ... } }
delay(200L) println("Task from runBlocking") } coroutineScope { // Creates a coroutine scope launch { delay(500L) println("Task from nested launch") } delay(100L) println("Task from coroutine scope") // This line will be printed before the nested launch } println("Coroutine scope is over") // This line is not printed until the nested launch completes }
4th language most loved by developers https://insights.stackoverflow.com/survey/2019# most-popular-technologies • 70% of the top 1000 Android apps use Kotlin https://developer.android.com/kotlin/stories