SlideShare a Scribd company logo
Let’s Try Kotlin!!
Try English LT! for engineers
2023-01-07(Sat)
へー/heisy(SASAKURA Hideyuki)
My Profile
● へー/heisy(SASAKURA Hideyuki)
○ Twitter : @heisy
● IT Engineer
● Likes
○ AWS
○ Java
○ Kotlin
○ DDD / TDD
○ Bouldering & Climbing
○ Drinking 🍶🍶🍶
Introduction
KotlinFest2022 on 10th Dec 2022.
I was Staff.
But…
Introduction
I don’t touch Kotlin for several years
😭
Introduction
So I’m Kotlin Lover if not much of one,
I restart Kotlin this year !!
As beginner…😓
Agenda
● Why Kotlin?
● How learn Kotlin ?
● More enjoy coding with Kotlin
Why Kotlin?
● Concise
● Safe
● Expressive
● Interoperable
● Multiplatform
Why Kotlin?: Concise
data class Employee(
val name: String,
val email: String,
val company: String
) // + automatically generated equals(), hashCode(), toString(), and copy()
object MyCompany { // A singleton
const val name: String = "MyCompany"
}
fun main() { // Function at the top level
val employee = Employee("Alice", // No `new` keyword
"alice@mycompany.com", MyCompany.name)
println(employee)
}
Why Kotlin?: Safe
fun reply(condition: Boolean): String? = // Nullability is part of Kotlin’s type system
if (condition) "I'm fine" else null
fun error(): Nothing = // Always throw an exception
throw IllegalStateException("Shouldn't be here")
fun main() {
val condition = true // Try replacing `true` with `false` and run the sample!
val message = reply(condition) // The result is nullable
// println(message.uppercase()) // This line doesn't compile
println(message?.replace("fine", "okay")) // Access a nullable value in a safe manner
if (message != null) { // If you check that the type is right,
println(message.uppercase()) // the compiler will smart-cast it for you
}
val nonNull: String = // If the null-case throws an error,
reply(condition = true) ?: error() // Kotlin can infer that the result is non-null
println(nonNull)
}
Why Kotlin?: Expressive
val map = mapOf(1 to "one", 2 to "two")
for ((k, v) in map) { // Traverse a map or a list of pairs
println("$k -> $v")
}
Why Kotlin?: Expressive
fun obtainKnowledge() = Pair("The Answer", 42) // Single-expression functions
val (description, answer) = obtainKnowledge() // Destructure into a pair of two variables
println("$description: $answer")
getText()?.let { // Apply an action to a nullable expression
sendEmailTo("alice@example.com", it) // if it’s not null
}
Why Kotlin?: Expressive
createEmptyWindow()
.apply { // Configure properties of an object
width = 300
height = 200
isVisible = true
}.also { w -> // Perform an additional operation on a call chain
showWindow(w)
}
val fixedIssue = issueById["13456"]
?.takeIf { it.status == Status.FIXED } // Use the value only if the condition is true
println(fixedIssue)
Why Kotlin?: Interoperable
Kotlin use JVM library or framework.
Call Kotlin code from Java without an issue.
Why Kotlin?: Multiplatform
Kotlin is sharing same code across Android, iOS, Web apps,
JS.
How learn Kotlin?
Kotlin learning method is blow.
● Books
● Session/Training movies
● Programing
How learn Kotlin?
Kotlin Playground is one of best tools to learn Kotlin.
How learn Kotlin?
You will find it easy to get samples from play.kotlinlang.org.
How learn Kotlin?
Kotlin has Coroutines. It's exciting!
More enjoy coding with Kotlin
We enjoy Kotlin as follows.
● Android apps
● Spring
etc…
More enjoy coding with Kotlin
Android mobile development has been Kotlin-first.
More enjoy coding with Kotlin
Spring support building web application by Kotlin.
More enjoy coding with Kotlin
Visual Studio Code support building Kotlin Web application.
So Let’s Try Kotlin !!
End
Thank you !
Have a nice Kotlin!

More Related Content

PDF
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
PDF
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
PPTX
Introduction to kotlin and OOP in Kotlin
PDF
Practical tips for building apps with kotlin
PDF
Reducing boilerplate with Kotlin, KTX and Kotlin Android Extensions
PDF
Save time with kotlin in android development
PDF
Kotlin: maybe it's the right time
PDF
Android 101 - Kotlin ( Future of Android Development)
Davide Cerbo - Kotlin: forse è la volta buona - Codemotion Milan 2017
eMan Dev Meetup: Kotlin - A Language we should know it exists (part 02/03) 18...
Introduction to kotlin and OOP in Kotlin
Practical tips for building apps with kotlin
Reducing boilerplate with Kotlin, KTX and Kotlin Android Extensions
Save time with kotlin in android development
Kotlin: maybe it's the right time
Android 101 - Kotlin ( Future of Android Development)

Similar to Let's Try Kotlin (20)

PPTX
Mercury: A Functional Review
PDF
Elasticsearch's aggregations & esctl in action or how i built a cli tool...
PDF
JavaZone 2022 - Building Kotlin DSL.pdf
PPTX
Scala 3camp 2011
PDF
Kotlin: forse è la volta buona (Trento)
PPTX
Property based testing
PPTX
Introduction to kotlin + spring boot demo
PDF
Kotlin for Android Development
PDF
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
PPT
Polymorphism in C++ for beginners reference
PDF
JavaScript - new features in ECMAScript 6
PDF
Coding for Android on steroids with Kotlin
PDF
Be More Productive with Kotlin
PDF
Koin Quickstart
PDF
Kotlin coroutine - the next step for RxJava developer?
PDF
Having Fun with Kotlin Android - DILo Surabaya
PPTX
C# for C++ programmers
PDF
Kotlin for Android - Vali Iorgu - mRready
PDF
The What, Why And How of ClojureScript
Mercury: A Functional Review
Elasticsearch's aggregations & esctl in action or how i built a cli tool...
JavaZone 2022 - Building Kotlin DSL.pdf
Scala 3camp 2011
Kotlin: forse è la volta buona (Trento)
Property based testing
Introduction to kotlin + spring boot demo
Kotlin for Android Development
Kotlin mufix 31 10-2019 by Ahmed Nabil(AhmedNMahran)
Polymorphism in C++ for beginners reference
JavaScript - new features in ECMAScript 6
Coding for Android on steroids with Kotlin
Be More Productive with Kotlin
Koin Quickstart
Kotlin coroutine - the next step for RxJava developer?
Having Fun with Kotlin Android - DILo Surabaya
C# for C++ programmers
Kotlin for Android - Vali Iorgu - mRready
The What, Why And How of ClojureScript
Ad

Recently uploaded (20)

PPTX
Foundation to blockchain - A guide to Blockchain Tech
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
DOCX
573137875-Attendance-Management-System-original
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Construction Project Organization Group 2.pptx
PDF
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PPT on Performance Review to get promotions
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
Sustainable Sites - Green Building Construction
PDF
Well-logging-methods_new................
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PDF
Digital Logic Computer Design lecture notes
PPTX
Geodesy 1.pptx...............................................
PDF
composite construction of structures.pdf
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
Foundation to blockchain - A guide to Blockchain Tech
CH1 Production IntroductoryConcepts.pptx
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
573137875-Attendance-Management-System-original
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Construction Project Organization Group 2.pptx
Enhancing Cyber Defense Against Zero-Day Attacks using Ensemble Neural Networks
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPT on Performance Review to get promotions
R24 SURVEYING LAB MANUAL for civil enggi
Sustainable Sites - Green Building Construction
Well-logging-methods_new................
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Digital Logic Computer Design lecture notes
Geodesy 1.pptx...............................................
composite construction of structures.pdf
Model Code of Practice - Construction Work - 21102022 .pdf
Ad

Let's Try Kotlin

  • 1. Let’s Try Kotlin!! Try English LT! for engineers 2023-01-07(Sat) へー/heisy(SASAKURA Hideyuki)
  • 2. My Profile ● へー/heisy(SASAKURA Hideyuki) ○ Twitter : @heisy ● IT Engineer ● Likes ○ AWS ○ Java ○ Kotlin ○ DDD / TDD ○ Bouldering & Climbing ○ Drinking 🍶🍶🍶
  • 3. Introduction KotlinFest2022 on 10th Dec 2022. I was Staff. But…
  • 4. Introduction I don’t touch Kotlin for several years 😭
  • 5. Introduction So I’m Kotlin Lover if not much of one, I restart Kotlin this year !! As beginner…😓
  • 6. Agenda ● Why Kotlin? ● How learn Kotlin ? ● More enjoy coding with Kotlin
  • 7. Why Kotlin? ● Concise ● Safe ● Expressive ● Interoperable ● Multiplatform
  • 8. Why Kotlin?: Concise data class Employee( val name: String, val email: String, val company: String ) // + automatically generated equals(), hashCode(), toString(), and copy() object MyCompany { // A singleton const val name: String = "MyCompany" } fun main() { // Function at the top level val employee = Employee("Alice", // No `new` keyword "alice@mycompany.com", MyCompany.name) println(employee) }
  • 9. Why Kotlin?: Safe fun reply(condition: Boolean): String? = // Nullability is part of Kotlin’s type system if (condition) "I'm fine" else null fun error(): Nothing = // Always throw an exception throw IllegalStateException("Shouldn't be here") fun main() { val condition = true // Try replacing `true` with `false` and run the sample! val message = reply(condition) // The result is nullable // println(message.uppercase()) // This line doesn't compile println(message?.replace("fine", "okay")) // Access a nullable value in a safe manner if (message != null) { // If you check that the type is right, println(message.uppercase()) // the compiler will smart-cast it for you } val nonNull: String = // If the null-case throws an error, reply(condition = true) ?: error() // Kotlin can infer that the result is non-null println(nonNull) }
  • 10. Why Kotlin?: Expressive val map = mapOf(1 to "one", 2 to "two") for ((k, v) in map) { // Traverse a map or a list of pairs println("$k -> $v") }
  • 11. Why Kotlin?: Expressive fun obtainKnowledge() = Pair("The Answer", 42) // Single-expression functions val (description, answer) = obtainKnowledge() // Destructure into a pair of two variables println("$description: $answer") getText()?.let { // Apply an action to a nullable expression sendEmailTo("alice@example.com", it) // if it’s not null }
  • 12. Why Kotlin?: Expressive createEmptyWindow() .apply { // Configure properties of an object width = 300 height = 200 isVisible = true }.also { w -> // Perform an additional operation on a call chain showWindow(w) } val fixedIssue = issueById["13456"] ?.takeIf { it.status == Status.FIXED } // Use the value only if the condition is true println(fixedIssue)
  • 13. Why Kotlin?: Interoperable Kotlin use JVM library or framework. Call Kotlin code from Java without an issue.
  • 14. Why Kotlin?: Multiplatform Kotlin is sharing same code across Android, iOS, Web apps, JS.
  • 15. How learn Kotlin? Kotlin learning method is blow. ● Books ● Session/Training movies ● Programing
  • 16. How learn Kotlin? Kotlin Playground is one of best tools to learn Kotlin.
  • 17. How learn Kotlin? You will find it easy to get samples from play.kotlinlang.org.
  • 18. How learn Kotlin? Kotlin has Coroutines. It's exciting!
  • 19. More enjoy coding with Kotlin We enjoy Kotlin as follows. ● Android apps ● Spring etc…
  • 20. More enjoy coding with Kotlin Android mobile development has been Kotlin-first.
  • 21. More enjoy coding with Kotlin Spring support building web application by Kotlin.
  • 22. More enjoy coding with Kotlin Visual Studio Code support building Kotlin Web application.
  • 23. So Let’s Try Kotlin !!
  • 24. End
  • 25. Thank you ! Have a nice Kotlin!