(Go: >> BACK << -|- >> HOME <<)

SlideShare a Scribd company logo
Intro to Kotlin
15.10.2015@Infinum Dino Sulić & Tomislav Homan
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
Java on Android - the bad parts
● Java 7 was out 2011. - partial support 2013.
● Java 8 was out 2014. - no support announced in the near future
● Null references
● Covariant arrays
● Raw types
● SAM types
● Checked exceptions
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
Alternatives to Java
● Xtend - Nice try, but very hard to work with in practice because
of IDE support
● Scala - We are engineers with deadlines, not scientists. Also 80k
methods
● Groovy - Very nice, but not type safe and adds over 30k
methods. IMHO best alternative - to our alternative :)
● Closure, etc, etc…
● Kotlin
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
Advantages of Kotlin (I)
● Modern statically typed, object oriented language that borrows
many ideas from functional languages
● Fast learning curve - inspired by Scala and C#. Scaled down
Scala :)
● Meant to be used for building large software systems
● Engineered to be highly interoperable with Java - you can use
existing code base w/o (many) problems
Advantages of Kotlin (II)
● The team behind it is JetBrains, creators of IntelliJ which is
Android Studio based on. Also has some contributions from
James Strachan - creator of Groovy
● Significantly more concise and readable than Java, which
means it’s easier to maintain
● Lightweight - Kotlin stdlib has 8k methods
● If it means something to someone - it also compiles to
Javascript
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
(Possible) disadvantages (I)
● Code generation - After a long struggle works with, for now,
limited support - Dagger 2 works
● Mocking and testing - managed to run AndroidTestCase with
Mockito, but no serious testing done
● IDE was still bit unstable few months ago, but it seems fine now
and it can only get better. But still be patient for now
(Possible) disadvantages (II)
● Java could break when using immutable collections returned
from Kotlin code
● New language that still evolves - teams need to establish code
conventions - still no "Effective Kotlin" :)
● Interoperability with new Jack and Jill compiler - should be all
right, but we have to monitor the situation
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
Features
Selection of features compared to
Java
First thing that one will notice is function declaration includes
keyword fun
Functions (I)
Parameter types are defined in Scala (Or Swift) way
Functions (II)
Default parameters come in handy
Functions (III)
Named parameters as a good substitution for builders
Functions (IV)
Functions are first-class Kotlin citizens
Functions (V)
Lambdas on Android? Not using Java
Functions (VI)
Lambdas on Android? Kotlin has them
Functions (VII)
Nice Retrofit example - cumbersome using Java
Functions (VIII)
Nice Retrofit example - pretty decent using Kotlin
Functions (IX)
Utility methods vs. extension functions
Functions (X)
Kotlin inferes types
Types (I)
It is difficult to write “final”. Kotlin makes it easier with val keyword
Types (II)
Java fields become Kotlin property. No need for getter / setters
unless you want to override them
Properties (I)
If you have the need for some validation…
Properties (II)
...you can still override accessors and access backing field
Properties (III)
Nothing to say here
Null safety (I)
You have to explicitly use nullable type if you want to allow nulls
Null safety (II)
If you use nulls though, safe calls, Elvis and smart casts are here to
help
Null safety (III)
Explicit vs. smart casts
Casting
In order to make this business logic right….
Data classes (I)
You have to do some work
Data classes (II)
In order to make this business logic right….
Data classes (III)
...you use data modifier
Data classes (IV)
Typical data repository
Collections (I)
Some business logic
Collections (II)
And lots of error prone work
Collections (III)
Same typical repository
Collections (IV)
Some business logic. Collections are really immutable
Collections (V)
But much less work
Collections (VI)
Just one more example...
Various (I)
...how Kotlin gets some things better
Various (II)
Out of scope
● Generics - variance, covariance, contravariance
● Annotations
● Reflection
● Operator overloading
● Type-safe builders
● Dynamic types
● Java interop
● …and lot more
● http://kotlinlang.org/docs/reference/
Content
● Java on Android - the bad parts
● Alternatives to Java
● Advantages of Kotlin
● (Possible) disadvantages
● Features
● …
● Migration to Kotlin
Migration to Koltin
● https://kotlinlang.org/docs/tutorials/kotlin-android.html
● Use convert code option - but check thoroughly afterwards
● Use clean code option after upgrading Kotlin version
● KotlinFrontEndException
● > sudo find . -name ".DS_Store" -depth -exec rm {} ;
● This list was much longer few months ago
Intro to kotlin

More Related Content

What's hot

Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
Atif AbbAsi
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Hardik Trivedi
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
Ekta Raj
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Lauren Yew
 
Kotlin on android
Kotlin on androidKotlin on android
Kotlin on android
Kurt Renzo Acosta
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022
Simplilearn
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | Edureka
Edureka!
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
Andreas Jakl
 
Kotlin
KotlinKotlin
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
Abdul Rahman Masri Attal
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
T.M. Ishrak Hussain
 
Kotlin
KotlinKotlin
Kotlin
Ravi Pawar
 
Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
Syed Awais Mazhar Bukhari
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
takshilkunadia
 
Introduction to kotlin coroutines
Introduction to kotlin coroutinesIntroduction to kotlin coroutines
Introduction to kotlin coroutines
NAVER Engineering
 
Kotlin
KotlinKotlin
Kotlin
Rory Preddy
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021
Nelson Glauber Leal
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
Dariusz Lorenc
 
Hibernate
HibernateHibernate
Hibernate
Ajay K
 

What's hot (20)

Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I Introduction to Koltin for Android Part I
Introduction to Koltin for Android Part I
 
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017Introduction to kotlin for android app development   gdg ahmedabad dev fest 2017
Introduction to kotlin for android app development gdg ahmedabad dev fest 2017
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
 
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin CoroutinesThreading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
Threading Made Easy! A Busy Developer’s Guide to Kotlin Coroutines
 
Kotlin on android
Kotlin on androidKotlin on android
Kotlin on android
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022Kotlin InDepth Tutorial for beginners 2022
Kotlin InDepth Tutorial for beginners 2022
 
Kotlin vs Java | Edureka
Kotlin vs Java | EdurekaKotlin vs Java | Edureka
Kotlin vs Java | Edureka
 
Android Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - IntroductionAndroid Development with Kotlin, Part 1 - Introduction
Android Development with Kotlin, Part 1 - Introduction
 
Kotlin
KotlinKotlin
Kotlin
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Kotlin
KotlinKotlin
Kotlin
 
Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
 
Introduction to kotlin coroutines
Introduction to kotlin coroutinesIntroduction to kotlin coroutines
Introduction to kotlin coroutines
 
Kotlin
KotlinKotlin
Kotlin
 
Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021Android Jetpack Compose - Turkey 2021
Android Jetpack Compose - Turkey 2021
 
Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Hibernate
HibernateHibernate
Hibernate
 

Similar to Intro to kotlin

Say Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentSay Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android Development
Adam Magaña
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overview
Ayman Mahfouz
 
Kotlin - A Programming Language
Kotlin - A Programming Language Kotlin - A Programming Language
Kotlin - A Programming Language
Mobio Solutions
 
Kotlin
KotlinKotlin
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
Jayaprakash R
 
Kotlin vs Java • Bapusaheb Patil • TechieAid Talk
Kotlin vs Java • Bapusaheb Patil • TechieAid TalkKotlin vs Java • Bapusaheb Patil • TechieAid Talk
Kotlin vs Java • Bapusaheb Patil • TechieAid Talk
Bapusaheb Patil
 
Is this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin languageIs this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin language
Antonis Lilis
 
Introduction_to_Kotlin.pptx
Introduction_to_Kotlin.pptxIntroduction_to_Kotlin.pptx
Introduction_to_Kotlin.pptx
HARSHITJAIN068
 
The Journey of Craftmanship – Kotlin in Action
The Journey of Craftmanship – Kotlin in ActionThe Journey of Craftmanship – Kotlin in Action
The Journey of Craftmanship – Kotlin in Action
raditya gumay
 
MOOC_PRESENTATION_KOTLIN[1].pptx
MOOC_PRESENTATION_KOTLIN[1].pptxMOOC_PRESENTATION_KOTLIN[1].pptx
MOOC_PRESENTATION_KOTLIN[1].pptx
kamalkantmaurya1
 
moocs_ppt.pptx
moocs_ppt.pptxmoocs_ppt.pptx
moocs_ppt.pptx
kamalkantmaurya1
 
Groovy android
Groovy androidGroovy android
Groovy android
Mario García
 
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
mCloud
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
Everything You Were Taught About Java Is Wrong
Everything You Were Taught About Java Is WrongEverything You Were Taught About Java Is Wrong
Everything You Were Taught About Java Is Wrong
Tim Boudreau
 
A short introduction to the Kotlin language for Java developers
A short introduction to the Kotlin language for Java developersA short introduction to the Kotlin language for Java developers
A short introduction to the Kotlin language for Java developers
Antonis Lilis
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
Vasil Remeniuk
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
Alex Ershov
 
Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?
Jérôme Petazzoni
 
Lightning talk: Kotlin
Lightning talk: KotlinLightning talk: Kotlin
Lightning talk: Kotlin
Evolve
 

Similar to Intro to kotlin (20)

Say Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android DevelopmentSay Goodbye To Java: Getting Started With Kotlin For Android Development
Say Goodbye To Java: Getting Started With Kotlin For Android Development
 
Modern Programming Languages - An overview
Modern Programming Languages - An overviewModern Programming Languages - An overview
Modern Programming Languages - An overview
 
Kotlin - A Programming Language
Kotlin - A Programming Language Kotlin - A Programming Language
Kotlin - A Programming Language
 
Kotlin
KotlinKotlin
Kotlin
 
Exploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App developmentExploring Kotlin language basics for Android App development
Exploring Kotlin language basics for Android App development
 
Kotlin vs Java • Bapusaheb Patil • TechieAid Talk
Kotlin vs Java • Bapusaheb Patil • TechieAid TalkKotlin vs Java • Bapusaheb Patil • TechieAid Talk
Kotlin vs Java • Bapusaheb Patil • TechieAid Talk
 
Is this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin languageIs this Swift for Android? A short introduction to the Kotlin language
Is this Swift for Android? A short introduction to the Kotlin language
 
Introduction_to_Kotlin.pptx
Introduction_to_Kotlin.pptxIntroduction_to_Kotlin.pptx
Introduction_to_Kotlin.pptx
 
The Journey of Craftmanship – Kotlin in Action
The Journey of Craftmanship – Kotlin in ActionThe Journey of Craftmanship – Kotlin in Action
The Journey of Craftmanship – Kotlin in Action
 
MOOC_PRESENTATION_KOTLIN[1].pptx
MOOC_PRESENTATION_KOTLIN[1].pptxMOOC_PRESENTATION_KOTLIN[1].pptx
MOOC_PRESENTATION_KOTLIN[1].pptx
 
moocs_ppt.pptx
moocs_ppt.pptxmoocs_ppt.pptx
moocs_ppt.pptx
 
Groovy android
Groovy androidGroovy android
Groovy android
 
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor BuzatovićJavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
 
Everything You Were Taught About Java Is Wrong
Everything You Were Taught About Java Is WrongEverything You Were Taught About Java Is Wrong
Everything You Were Taught About Java Is Wrong
 
A short introduction to the Kotlin language for Java developers
A short introduction to the Kotlin language for Java developersA short introduction to the Kotlin language for Java developers
A short introduction to the Kotlin language for Java developers
 
Effective Scala: Programming Patterns
Effective Scala: Programming PatternsEffective Scala: Programming Patterns
Effective Scala: Programming Patterns
 
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]26 top angular 8 interview questions to know in 2020   [www.full stack.cafe]
26 top angular 8 interview questions to know in 2020 [www.full stack.cafe]
 
Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?Docker and Go: why did we decide to write Docker in Go?
Docker and Go: why did we decide to write Docker in Go?
 
Lightning talk: Kotlin
Lightning talk: KotlinLightning talk: Kotlin
Lightning talk: Kotlin
 

Recently uploaded

Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Asher Sterkin
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
Ortus Solutions, Corp
 
Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02
williamrobertherman
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
Ortus Solutions, Corp
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
Ortus Solutions, Corp
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
avufu
 
dachnug51 - HCL Domino Roadmap .pdf
dachnug51 - HCL Domino Roadmap      .pdfdachnug51 - HCL Domino Roadmap      .pdf
dachnug51 - HCL Domino Roadmap .pdf
DNUG e.V.
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
Severalnines
 
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
Ortus Solutions, Corp
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
DNUG e.V.
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
williamrobertherman
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
MaisnamLuwangPibarel
 
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
Misti Soneji
 
Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?
Ortus Solutions, Corp
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
Hironori Washizaki
 
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdfWhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
onemonitarsoftware
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
DNUG e.V.
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
Ortus Solutions, Corp
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
AUGNYC
 

Recently uploaded (20)

Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
Ported to Cloud with Wing_ Blue ZnZone app from _Hexagonal Architecture Expla...
 
Migrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS CloudMigrate your Infrastructure to the AWS Cloud
Migrate your Infrastructure to the AWS Cloud
 
Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02Java SE 17 Study Guide for Certification - Chapter 02
Java SE 17 Study Guide for Certification - Chapter 02
 
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
Abortion pills in Fujairah *((+971588192166*)☎️)¥) **Effective Abortion Pills...
 
Securing Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecuritySecuring Your Application with Passkeys and cbSecurity
Securing Your Application with Passkeys and cbSecurity
 
How we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hoursHow we built TryBoxLang in under 48 hours
How we built TryBoxLang in under 48 hours
 
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
一比一原版英国牛津大学毕业证(oxon毕业证书)如何办理
 
dachnug51 - HCL Domino Roadmap .pdf
dachnug51 - HCL Domino Roadmap      .pdfdachnug51 - HCL Domino Roadmap      .pdf
dachnug51 - HCL Domino Roadmap .pdf
 
WEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service ProvidersWEBINAR SLIDES: CCX for Cloud Service Providers
WEBINAR SLIDES: CCX for Cloud Service Providers
 
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
How to debug ColdFusion Applications using “ColdFusion Builder extension for ...
 
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdfdachnug51 - HCL Sametime 12 as a Software Appliance.pdf
dachnug51 - HCL Sametime 12 as a Software Appliance.pdf
 
Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01Java SE 17 Study Guide for Certification - Chapter 01
Java SE 17 Study Guide for Certification - Chapter 01
 
Development of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML TechnologiesDevelopment of Chatbot Using AI\ML Technologies
Development of Chatbot Using AI\ML Technologies
 
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe@ℂall @Girls Kolkata  ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
@ℂall @Girls Kolkata ꧁❤ 000000000 ❤꧂@ℂall @Girls Service Vip Top Model Safe
 
Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?Schrodinger’s Backup: Is Your Backup Really a Backup?
Schrodinger’s Backup: Is Your Backup Really a Backup?
 
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
COMPSAC 2024 D&I Panel: Charting a Course for Equity: Strategies for Overcomi...
 
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdfWhatsApp Tracker -  Tracking WhatsApp to Boost Online Safety.pdf
WhatsApp Tracker - Tracking WhatsApp to Boost Online Safety.pdf
 
dachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdfdachnug51 - HCLs evolution of the employee experience platform.pdf
dachnug51 - HCLs evolution of the employee experience platform.pdf
 
Intro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AIIntro to Amazon Web Services (AWS) and Gen AI
Intro to Amazon Web Services (AWS) and Gen AI
 
NYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdfNYC 26-Jun-2024 Combined Presentations.pdf
NYC 26-Jun-2024 Combined Presentations.pdf
 

Intro to kotlin

  • 1. Intro to Kotlin 15.10.2015@Infinum Dino Sulić & Tomislav Homan
  • 2. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 3. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 4. Java on Android - the bad parts ● Java 7 was out 2011. - partial support 2013. ● Java 8 was out 2014. - no support announced in the near future ● Null references ● Covariant arrays ● Raw types ● SAM types ● Checked exceptions
  • 5. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 6. Alternatives to Java ● Xtend - Nice try, but very hard to work with in practice because of IDE support ● Scala - We are engineers with deadlines, not scientists. Also 80k methods ● Groovy - Very nice, but not type safe and adds over 30k methods. IMHO best alternative - to our alternative :) ● Closure, etc, etc… ● Kotlin
  • 7. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 8. Advantages of Kotlin (I) ● Modern statically typed, object oriented language that borrows many ideas from functional languages ● Fast learning curve - inspired by Scala and C#. Scaled down Scala :) ● Meant to be used for building large software systems ● Engineered to be highly interoperable with Java - you can use existing code base w/o (many) problems
  • 9. Advantages of Kotlin (II) ● The team behind it is JetBrains, creators of IntelliJ which is Android Studio based on. Also has some contributions from James Strachan - creator of Groovy ● Significantly more concise and readable than Java, which means it’s easier to maintain ● Lightweight - Kotlin stdlib has 8k methods ● If it means something to someone - it also compiles to Javascript
  • 10. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 11. (Possible) disadvantages (I) ● Code generation - After a long struggle works with, for now, limited support - Dagger 2 works ● Mocking and testing - managed to run AndroidTestCase with Mockito, but no serious testing done ● IDE was still bit unstable few months ago, but it seems fine now and it can only get better. But still be patient for now
  • 12. (Possible) disadvantages (II) ● Java could break when using immutable collections returned from Kotlin code ● New language that still evolves - teams need to establish code conventions - still no "Effective Kotlin" :) ● Interoperability with new Jack and Jill compiler - should be all right, but we have to monitor the situation
  • 13. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 14. Features Selection of features compared to Java
  • 15. First thing that one will notice is function declaration includes keyword fun Functions (I)
  • 16. Parameter types are defined in Scala (Or Swift) way Functions (II)
  • 17. Default parameters come in handy Functions (III)
  • 18. Named parameters as a good substitution for builders Functions (IV)
  • 19. Functions are first-class Kotlin citizens Functions (V)
  • 20. Lambdas on Android? Not using Java Functions (VI)
  • 21. Lambdas on Android? Kotlin has them Functions (VII)
  • 22. Nice Retrofit example - cumbersome using Java Functions (VIII)
  • 23. Nice Retrofit example - pretty decent using Kotlin Functions (IX)
  • 24. Utility methods vs. extension functions Functions (X)
  • 26. It is difficult to write “final”. Kotlin makes it easier with val keyword Types (II)
  • 27. Java fields become Kotlin property. No need for getter / setters unless you want to override them Properties (I)
  • 28. If you have the need for some validation… Properties (II)
  • 29. ...you can still override accessors and access backing field Properties (III)
  • 30. Nothing to say here Null safety (I)
  • 31. You have to explicitly use nullable type if you want to allow nulls Null safety (II)
  • 32. If you use nulls though, safe calls, Elvis and smart casts are here to help Null safety (III)
  • 33. Explicit vs. smart casts Casting
  • 34. In order to make this business logic right…. Data classes (I)
  • 35. You have to do some work Data classes (II)
  • 36. In order to make this business logic right…. Data classes (III)
  • 37. ...you use data modifier Data classes (IV)
  • 40. And lots of error prone work Collections (III)
  • 42. Some business logic. Collections are really immutable Collections (V)
  • 43. But much less work Collections (VI)
  • 44. Just one more example... Various (I)
  • 45. ...how Kotlin gets some things better Various (II)
  • 46. Out of scope ● Generics - variance, covariance, contravariance ● Annotations ● Reflection ● Operator overloading ● Type-safe builders ● Dynamic types ● Java interop ● …and lot more ● http://kotlinlang.org/docs/reference/
  • 47. Content ● Java on Android - the bad parts ● Alternatives to Java ● Advantages of Kotlin ● (Possible) disadvantages ● Features ● … ● Migration to Kotlin
  • 48. Migration to Koltin ● https://kotlinlang.org/docs/tutorials/kotlin-android.html ● Use convert code option - but check thoroughly afterwards ● Use clean code option after upgrading Kotlin version ● KotlinFrontEndException ● > sudo find . -name ".DS_Store" -depth -exec rm {} ; ● This list was much longer few months ago