SlideShare a Scribd company logo
Kotlin from scratch
franco.lombardo@smeup.com - https://www.linkedin.com/in/francolombardo/
Kotlin
The five Wh questions
• What?
• Who?
• When?
• Where?
• Why?
What is Kotlin?
Kotlin is a programming language
with a syntax similar to C / Java / JavaScript / C#
• Strong typing (a number is not a string)
• Static typing (types of variables are checked at
compile time)
• Type inference (type declaration can often be omitted)
• Object Oriented Programming (classes, objects,
methods, inheritance, polymorphic calls)
• Functional Programming Paradigm (functions are
types, so we can pass them around)
Who created Kotlin?
• Kotlin was created by JetBrains, a company that
builds programming languages IDEs and tools
such as IntelliJ IDEA
• There is a Kotlin Foundation created with Google to
protect the trademarks and to design the development
path
• Open source licensed under Apache 2
• Kotlin is the name of an island near St. Petersburg
(Java is the name of an island, too)
When was Kotlin created?
• 2010: Start of the Kotlin project
• 2012: The project becomes Open Source
• 2016: First stable release
• 2017: Google announces support on Android
• 2019: It becomes the preferred language for Android
Where does Kotlin run?
• JVM: primary target, the only one that is battle-proven
• JS: browser and server (NodeJS) (early stage)
• Native: iOS and more (early stage)
Be careful: cross platform code cannot use Java libraries!
Why Kotlin?
• It’s modern (OOP + functional + coroutines +…)
• It’s concise
• It’s interoperable
• it can reuse Java libraries ecosystem
• it can be used by Java projects
• It’s multiplatform (maybe?)
• It handles null values in a safer way
• Decoupling the evolution of the language from the
evolution of the JVM (e.g. phones, AS400, mission
critical production servers)
Why Kotlin?
Working in Kotlin is a lot of fun!
J
The very recommended IDE for Kotlin
The very recommended IDE for Kotlin
The very recommended IDE for Kotlin
The very recommended
building system for Kotlin
Sample project: https://github.com/f-lombardo/kotlin-from-scratch
Strong static typing with inference
fun main() {
val authorOfNabucco: String = "Giuseppe Verdi"
val authorOfTurandot = "Giacomo Puccini"
println("Italian composers: $authorOfNabucco and $authorOfTurandot")
}
Strong static typing with inference
fun main() {
val authorOfNabucco: String = "Giuseppe Verdi"
val authorOfTurandot = "Giacomo Puccini"
println("Italian composers: $authorOfNabucco and $authorOfTurandot")
}
Explicit type declaration
Type inference
String
interpolation
Immutable variables are preferred
Multiline strings: Kotlin is concise
Test blocks of RPG CODE easily
Kotlin is concise: why is it important?
Concise
↓
Less boilerplate code
↓
Easier to understand
(less cognitive overload)
↓
Fewer bugs
How much is Kotlin concise?
Data class: Java Bean with
hashCode, toString, equals and much more
How much is Kotlin concise?
Decompiled Java version
of the previous data class
(just a part of it)
Default arguments
Default arguments = less overloading!!!
Kotlin is safer
Can be null
Cannot be null
val italianComposer: String = "Giuseppe Verdi"
val dutchComposer: String? = null
val result =
openDatabase("franco", "secret")
?.findFirstComposerByNation("Italy")
?.findOperaByYear(1871)
?: "No results"
Kotlin is safer
Composing nullable values/functions
in a safe way
Possibly null
Not null
val result =
openDatabase("franco", "secret")
?.findFirstComposerByNation("Italy")
?.findOperaByYear(1871)
?: "No results"
Kotlin is safer
Composing nullable values/functions
in an expressive way
“or else”“and then”
Extension functions
data class Database(val composers: List<Composer>)
data class Composer(val name: String,
val nation: String,
val operas: List<Opera>)
data class Opera(val name: String, val yearOfComposition: Int)
fun Database.findFirstComposerByNation(nation: String): Composer? =
this.composers.firstOrNull { it.nation == nation }
fun Composer.findOperaByYear(year: Int): Opera? =
this.operas.firstOrNull { it.yearOfComposition == year }
Extending classes from outside
Extension functions
Code organization based on domain aspects
Extension methods for domain objects
regarding the “SQL aspect”
The power of lambdas
val elapsedTime = measureTimeMillis {
execute(compilationUnit.main.stmts)
}
public fun measureTimeMillis(block: () -> Unit): Long {
val start = System.currentTimeMillis()
block()
return System.currentTimeMillis() - start
}
References
Kotlin in action
Dmitry Jemerov, Svetlana Isakova
Kotlin for Java Developers
https://www.coursera.org/learn/kotlin-for-java-developers
JetBrains Kotlin Academy
https://hyperskill.org/onboarding/?track=kotlin
JetBrains Kotlin playlist on YouTube
https://bit.ly/kotlinTube
Kotlin hands-on labs (Coroutines, JS, Native)
https://play.kotlinlang.org/hands-on/overview

More Related Content

What's hot (20)

PPTX
Intro to Kotlin Minia GDG DevFest 2017
Shady Selim
 
PPTX
What's Kotlin and Why?
Pouya Heydari
 
PDF
Kotlin & Arrow the functional way
Thoughtworks
 
KEY
Using Aspects for Language Portability (SCAM 2010)
lennartkats
 
KEY
Remix Your Language Tooling (JSConf.eu 2012)
lennartkats
 
PDF
Kotlin & arrow: the functional way
nluaces
 
PDF
A short introduction to the Kotlin language for Java developers
Antonis Lilis
 
PDF
Dove sono i tuoi vertici e di cosa stanno parlando?
Codemotion
 
PDF
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
PDF
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
mametter
 
PPT
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
PPTX
Scala - the good, the bad and the very ugly
Bozhidar Bozhanov
 
KEY
Scala
guest8996422d
 
PDF
Generators, Coroutines and Other Brain Unrolling Sweetness. Adi Shavit ➠ Cor...
corehard_by
 
PPTX
C-Sharp 6.0 ver2
Tome Tomovski
 
KEY
Future of PHP
Richard McIntyre
 
ODP
Enrich Your Models With OCL
Edward Willink
 
PDF
Scala the-good-parts
Fuqiang Wang
 
PPT
Intro to Java for C++ Developers
Zachary Blair
 
Intro to Kotlin Minia GDG DevFest 2017
Shady Selim
 
What's Kotlin and Why?
Pouya Heydari
 
Kotlin & Arrow the functional way
Thoughtworks
 
Using Aspects for Language Portability (SCAM 2010)
lennartkats
 
Remix Your Language Tooling (JSConf.eu 2012)
lennartkats
 
Kotlin & arrow: the functional way
nluaces
 
A short introduction to the Kotlin language for Java developers
Antonis Lilis
 
Dove sono i tuoi vertici e di cosa stanno parlando?
Codemotion
 
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
A Static Type Analyzer of Untyped Ruby Code for Ruby 3
mametter
 
A First Look at Google's Go Programming Language
Ganesh Samarthyam
 
Scala - the good, the bad and the very ugly
Bozhidar Bozhanov
 
Generators, Coroutines and Other Brain Unrolling Sweetness. Adi Shavit ➠ Cor...
corehard_by
 
C-Sharp 6.0 ver2
Tome Tomovski
 
Future of PHP
Richard McIntyre
 
Enrich Your Models With OCL
Edward Willink
 
Scala the-good-parts
Fuqiang Wang
 
Intro to Java for C++ Developers
Zachary Blair
 

Similar to Kotlin from-scratch (20)

PDF
Kotlin what_you_need_to_know-converted event 4 with nigerians
junaidhasan17
 
PPTX
Android Development with Kotlin course
GoogleDevelopersLeba
 
PPTX
Android with kotlin course
Abdul Rahman Masri Attal
 
PDF
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
PROIDEA
 
PPTX
Kotlin
Sudhanshu Vohra
 
PPTX
Hello to Kotlin
FatimaYousif11
 
PDF
Kotlin for Android Developers - 1
Mohamed Nabil, MSc.
 
PPTX
Kotlin - A Programming Language
Mobio Solutions
 
PDF
Programming with Kotlin
David Gassner
 
PPTX
Introduction to Kotlin for Android developers
Mohamed Wael
 
PDF
JavaOne 2016 - Kotlin: The Language of The Future For JVM?
Leonardo Zanivan
 
PDF
Why You Should Go with Kotlin for Android App Development.pdf
RipenApps
 
PPTX
Kotlin Overview
Ekta Raj
 
PPTX
Coding in kotlin
Debmalya Jash
 
PDF
Android 101 - Kotlin ( Future of Android Development)
Hassan Abid
 
PDF
Kotlin in Action, Second Edition (MEAP V09) Svetlana Isakova
zemelduffys
 
PDF
What’s new in Kotlin?
Squareboat
 
PPTX
Why Kotlin?
Yongqiang Li
 
PDF
Kotlin for Android
Han Yin
 
Kotlin what_you_need_to_know-converted event 4 with nigerians
junaidhasan17
 
Android Development with Kotlin course
GoogleDevelopersLeba
 
Android with kotlin course
Abdul Rahman Masri Attal
 
JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)
PROIDEA
 
Hello to Kotlin
FatimaYousif11
 
Kotlin for Android Developers - 1
Mohamed Nabil, MSc.
 
Kotlin - A Programming Language
Mobio Solutions
 
Programming with Kotlin
David Gassner
 
Introduction to Kotlin for Android developers
Mohamed Wael
 
JavaOne 2016 - Kotlin: The Language of The Future For JVM?
Leonardo Zanivan
 
Why You Should Go with Kotlin for Android App Development.pdf
RipenApps
 
Kotlin Overview
Ekta Raj
 
Coding in kotlin
Debmalya Jash
 
Android 101 - Kotlin ( Future of Android Development)
Hassan Abid
 
Kotlin in Action, Second Edition (MEAP V09) Svetlana Isakova
zemelduffys
 
What’s new in Kotlin?
Squareboat
 
Why Kotlin?
Yongqiang Li
 
Kotlin for Android
Han Yin
 
Ad

More from Franco Lombardo (16)

PDF
Exploring AI riding an LLPhant - An Open Source Library to use LLMs and vecto...
Franco Lombardo
 
PDF
happiness_2023.pdf
Franco Lombardo
 
PDF
Kotlin from-scratch 3 - coroutines
Franco Lombardo
 
PDF
Kotlin from-scratch 2 - functions
Franco Lombardo
 
PPTX
Agile Venture Milan - Unit testing on AS400? Yes we can! (With Kotlin)
Franco Lombardo
 
PPTX
Unit testing on AS400? Yes we can! (With Kotlin)
Franco Lombardo
 
PPTX
Interprete Kotlin per l’RPG e libreria Web Components: Open Source per la m...
Franco Lombardo
 
PPTX
TDD su AS400? Con Kotlin si può fare! - Italian Agile Days 2019
Franco Lombardo
 
PPTX
Un interprete Kotlin per il linguaggio RPG AS400 - IBM i
Franco Lombardo
 
PPTX
Agile Happiness - Agile O'Day 2018
Franco Lombardo
 
PPTX
Agile Happiness 2
Franco Lombardo
 
PPTX
Agile Happiness
Franco Lombardo
 
PPT
Java per as400
Franco Lombardo
 
PDF
Rock scissors-paper-kata
Franco Lombardo
 
PPT
A First Date With Scala
Franco Lombardo
 
PPT
Primo Incontro Con Scala
Franco Lombardo
 
Exploring AI riding an LLPhant - An Open Source Library to use LLMs and vecto...
Franco Lombardo
 
happiness_2023.pdf
Franco Lombardo
 
Kotlin from-scratch 3 - coroutines
Franco Lombardo
 
Kotlin from-scratch 2 - functions
Franco Lombardo
 
Agile Venture Milan - Unit testing on AS400? Yes we can! (With Kotlin)
Franco Lombardo
 
Unit testing on AS400? Yes we can! (With Kotlin)
Franco Lombardo
 
Interprete Kotlin per l’RPG e libreria Web Components: Open Source per la m...
Franco Lombardo
 
TDD su AS400? Con Kotlin si può fare! - Italian Agile Days 2019
Franco Lombardo
 
Un interprete Kotlin per il linguaggio RPG AS400 - IBM i
Franco Lombardo
 
Agile Happiness - Agile O'Day 2018
Franco Lombardo
 
Agile Happiness 2
Franco Lombardo
 
Agile Happiness
Franco Lombardo
 
Java per as400
Franco Lombardo
 
Rock scissors-paper-kata
Franco Lombardo
 
A First Date With Scala
Franco Lombardo
 
Primo Incontro Con Scala
Franco Lombardo
 
Ad

Recently uploaded (20)

PDF
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
PPTX
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
PPTX
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
PDF
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
PDF
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PPTX
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
PPTX
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
PPTX
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
PPTX
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
PDF
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
PDF
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
PDF
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
PPTX
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
PDF
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
PDF
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PDF
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
PPTX
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
PPTX
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 
The 5 Reasons for IT Maintenance - Arna Softech
Arna Softech
 
Agentic Automation Journey Series Day 2 – Prompt Engineering for UiPath Agents
klpathrudu
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pptx
Varsha Nayak
 
Open Chain Q2 Steering Committee Meeting - 2025-06-25
Shane Coughlan
 
iTop VPN With Crack Lifetime Activation Key-CODE
utfefguu
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Foundations of Marketo Engage - Powering Campaigns with Marketo Personalization
bbedford2
 
ChiSquare Procedure in IBM SPSS Statistics Version 31.pptx
Version 1 Analytics
 
Help for Correlations in IBM SPSS Statistics.pptx
Version 1 Analytics
 
Agentic Automation Journey Session 1/5: Context Grounding and Autopilot for E...
klpathrudu
 
vMix Pro 28.0.0.42 Download vMix Registration key Bundle
kulindacore
 
Driver Easy Pro 6.1.1 Crack Licensce key 2025 FREE
utfefguu
 
Wondershare PDFelement Pro Crack for MacOS New Version Latest 2025
bashirkhan333g
 
Milwaukee Marketo User Group - Summer Road Trip: Mapping and Personalizing Yo...
bbedford2
 
HiHelloHR – Simplify HR Operations for Modern Workplaces
HiHelloHR
 
Why Businesses Are Switching to Open Source Alternatives to Crystal Reports.pdf
Varsha Nayak
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Odoo CRM vs Zoho CRM: Honest Comparison 2025
Odiware Technologies Private Limited
 
Empowering Asian Contributions: The Rise of Regional User Groups in Open Sour...
Shane Coughlan
 
Transforming Mining & Engineering Operations with Odoo ERP | Streamline Proje...
SatishKumar2651
 

Kotlin from-scratch

  • 1. Kotlin from scratch [email protected] - https://www.linkedin.com/in/francolombardo/
  • 2. Kotlin The five Wh questions • What? • Who? • When? • Where? • Why?
  • 3. What is Kotlin? Kotlin is a programming language with a syntax similar to C / Java / JavaScript / C# • Strong typing (a number is not a string) • Static typing (types of variables are checked at compile time) • Type inference (type declaration can often be omitted) • Object Oriented Programming (classes, objects, methods, inheritance, polymorphic calls) • Functional Programming Paradigm (functions are types, so we can pass them around)
  • 4. Who created Kotlin? • Kotlin was created by JetBrains, a company that builds programming languages IDEs and tools such as IntelliJ IDEA • There is a Kotlin Foundation created with Google to protect the trademarks and to design the development path • Open source licensed under Apache 2 • Kotlin is the name of an island near St. Petersburg (Java is the name of an island, too)
  • 5. When was Kotlin created? • 2010: Start of the Kotlin project • 2012: The project becomes Open Source • 2016: First stable release • 2017: Google announces support on Android • 2019: It becomes the preferred language for Android
  • 6. Where does Kotlin run? • JVM: primary target, the only one that is battle-proven • JS: browser and server (NodeJS) (early stage) • Native: iOS and more (early stage) Be careful: cross platform code cannot use Java libraries!
  • 7. Why Kotlin? • It’s modern (OOP + functional + coroutines +…) • It’s concise • It’s interoperable • it can reuse Java libraries ecosystem • it can be used by Java projects • It’s multiplatform (maybe?) • It handles null values in a safer way • Decoupling the evolution of the language from the evolution of the JVM (e.g. phones, AS400, mission critical production servers)
  • 8. Why Kotlin? Working in Kotlin is a lot of fun! J
  • 9. The very recommended IDE for Kotlin
  • 10. The very recommended IDE for Kotlin
  • 11. The very recommended IDE for Kotlin
  • 12. The very recommended building system for Kotlin Sample project: https://github.com/f-lombardo/kotlin-from-scratch
  • 13. Strong static typing with inference fun main() { val authorOfNabucco: String = "Giuseppe Verdi" val authorOfTurandot = "Giacomo Puccini" println("Italian composers: $authorOfNabucco and $authorOfTurandot") }
  • 14. Strong static typing with inference fun main() { val authorOfNabucco: String = "Giuseppe Verdi" val authorOfTurandot = "Giacomo Puccini" println("Italian composers: $authorOfNabucco and $authorOfTurandot") } Explicit type declaration Type inference String interpolation Immutable variables are preferred
  • 15. Multiline strings: Kotlin is concise Test blocks of RPG CODE easily
  • 16. Kotlin is concise: why is it important? Concise ↓ Less boilerplate code ↓ Easier to understand (less cognitive overload) ↓ Fewer bugs
  • 17. How much is Kotlin concise? Data class: Java Bean with hashCode, toString, equals and much more
  • 18. How much is Kotlin concise? Decompiled Java version of the previous data class (just a part of it)
  • 19. Default arguments Default arguments = less overloading!!!
  • 20. Kotlin is safer Can be null Cannot be null val italianComposer: String = "Giuseppe Verdi" val dutchComposer: String? = null
  • 21. val result = openDatabase("franco", "secret") ?.findFirstComposerByNation("Italy") ?.findOperaByYear(1871) ?: "No results" Kotlin is safer Composing nullable values/functions in a safe way Possibly null Not null
  • 22. val result = openDatabase("franco", "secret") ?.findFirstComposerByNation("Italy") ?.findOperaByYear(1871) ?: "No results" Kotlin is safer Composing nullable values/functions in an expressive way “or else”“and then”
  • 23. Extension functions data class Database(val composers: List<Composer>) data class Composer(val name: String, val nation: String, val operas: List<Opera>) data class Opera(val name: String, val yearOfComposition: Int) fun Database.findFirstComposerByNation(nation: String): Composer? = this.composers.firstOrNull { it.nation == nation } fun Composer.findOperaByYear(year: Int): Opera? = this.operas.firstOrNull { it.yearOfComposition == year } Extending classes from outside
  • 24. Extension functions Code organization based on domain aspects Extension methods for domain objects regarding the “SQL aspect”
  • 25. The power of lambdas val elapsedTime = measureTimeMillis { execute(compilationUnit.main.stmts) } public fun measureTimeMillis(block: () -> Unit): Long { val start = System.currentTimeMillis() block() return System.currentTimeMillis() - start }
  • 26. References Kotlin in action Dmitry Jemerov, Svetlana Isakova Kotlin for Java Developers https://www.coursera.org/learn/kotlin-for-java-developers JetBrains Kotlin Academy https://hyperskill.org/onboarding/?track=kotlin JetBrains Kotlin playlist on YouTube https://bit.ly/kotlinTube Kotlin hands-on labs (Coroutines, JS, Native) https://play.kotlinlang.org/hands-on/overview