Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Kotlin Everywhere: Versatility and Efficiency in Software Development

Kotlin Everywhere: Versatility and Efficiency in Software Development

'Kotlin Everywhere: Versatility and Efficiency in Software Development' is a talk given at DevFest 2023 by GDG Makurdi. It shows the versatility and efficiency when using Kotlin to develop powerful software.

Manuel Ernesto

December 03, 2023
Tweet

More Decks by Manuel Ernesto

Other Decks in Programming

Transcript

  1. Kotlin is a cross-platform, statically typed, general-purpose programming language with

    type inference developed by JetBrains. Kotlin interoperates fully with Java, and it can be used to write Android apps, IOS apps*, web applications, and other types of software. Makurdi
  2. 2016 2021 2022 2023 2024 Kotlin releases Kotlin 1.0 15

    Feb Kotlin 1.8.20 “Lang ver 2.0” Kotlin 1.9.x K2 Beta Compose & KSP Kotlin 2.0 K2 Default Kotlin 1.7.0 K2 Alpha Kotlin 2.0 & K2 Kotlin 1.5
  3. Kotlin is designed to be fully interoperable with Java, allowing

    developers to leverage existing Java libraries, frameworks, and tools. Makurdi Interoperability with Java
  4. Makurdi Calling Java from Kotlin import java.util.* fun demo(source: List<Int>)

    { val list = ArrayList<Int>() // 'for'-loops work for Java collections: for (item in source) { list.add(item) } // Operator conventions work as well: for (i in 0..source.size - 1) { list[i] = source[i] // get and set are called } }
  5. Kotlin's syntax is concise and expressive, reducing boilerplate code and

    enhancing code readability. Makurdi Conciseness and Readability
  6. Makurdi Data class /** * no need to define get,

    set, toString ... */ data class Address(var street: String, var streetNumber: Int, var postCode: String, var city: String, var country: Country)
  7. Kotlin introduces coroutines, which simplify asynchronous programming and make it

    more readable. Makurdi Coroutines for Asynchronous Programming
  8. Makurdi Async with Coroutines import kotlinx.coroutines.* suspend fun main() {

    // A function that can be suspended and resumed later val start = System.currentTimeMillis() coroutineScope { // Create a scope for starting coroutines for (i in 1..10) { launch { // Start 10 concurrent tasks delay(3000L - i * 300) // Pause their execution log(start, "Countdown: $i") } } } // Execution continues when all coroutines in the scope have finished log(start, "Liftoff!") }
  9. Kotlin supports extension functions, allowing developers to add new functions

    to existing classes without modifying their source code. Makurdi Extension Functions
  10. Makurdi Extension Functions fun MutableList<Int>.swap(index1: Int, index2: Int) { val

    tmp = this[index1] // 'this' corresponds to the list this[index1] = this[index2] this[index2] = tmp } val list = mutableListOf(1, 2, 3) list.swap(0, 2) // 'this' inside 'swap()' will hold the value of 'list'
  11. KMP allows developers to share code between different platforms, such

    as JVM and native. Makurdi Multiplatform Development
  12. Makurdi Server-side Combine the world’s most popular JVM framework with

    Kotlin and make the ultimate combo for application development.
  13. Makurdi Server-side Ktor is a multiplatform toolkit built by JetBrains

    for creating Web applications in Kotlin. It makes use of coroutines for high scalability and offers an easy-to-use API.