SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Say Goodbye to Java: Getting
Started With Kotlin for
Android
Adam Magaña
Introduction
Introduction
● Adam Magaña
● Lead Mobile Engineer @ Drund
● Currently spending most of my development time working on our Android
application.
A Quick History of Kotlin
A Quick History of Kotlin
● Created by JetBrains
○ Creator of IntelliJ, the IDE that powers Android Studio
● First release - July 2011
● Latest release (1.1.3) - June 2017
● Official endorsement by Google as first-class language - May 2017
● 8,000+ total releases on GitHub
“We believe Kotlin is an excellent fit for
Android not only because it gives
developers what they want, but also
because it matches the spirit of
Android.”
- Google Developer Product Group
Companies Using Kotlin
Companies Using Kotlin
● Pinterest
● Netflix
● AWS
● Uber
● Square
● Trello
10%
Reduction in total methods after converting Basecamp to Kotlin.
30%
Reduction in total lines of code after converting Basecamp to Kotlin.
Addressing Common Concerns
“But I’m comfortable and experienced
with Java.”
● That’s great!
● You ultimately have to use what you’re most comfortable with.
● BUT “give it 5 minutes” before reacting.
“I don’t want to convert my entire
codebase to a new language.”
● Kotlin can be any percentage of your project.
● Fully compatible with JDK 6.
● 100% interoperable with existing Java code.
“I don’t need Kotlin’s special tools to get
the job done.”
● An experienced developer absolutely doesn’t need Kotlin.
● Much can be accomplished with Java.
● BUT barring architectural/performance issues, why would you want
to have less tools available to you?
“I’m worried about the performance
implications of using Kotlin.”
● Performance is as good as an equivalent Java application.
● Kotlin lambdas often run faster than the same code written in Java.
● Incremental project builds using Kotlin are usually faster.
A Very Small Soapbox
A Very Small Soapbox
● Don’t let anyone, myself included, make you feel inadequate for choosing a
different programming language or platform than them.
● Will there be better alternatives to what you use? Yes.
● Does that mean the service you provide to your users is sub-par? No.
● Is it okay to have differing opinions about certain technologies? Absolutely.
● Important to be supportive.
We’re all in this together.
Setting Up Kotlin in Android
Studio
Setting Up Kotlin in Android Studio
● Extremely easy setup for both major versions of AS
● Plugin for AS 2.3.X
○ Preferences > Plugins > Install JetBrains Plugin
● Baked-in support in AS 3.0.0 (beta)
○ Also includes:
■ A new profiler tool
■ A network/request analyzer (!)
Installing the plugin for AS 2.3.X
Kotlin: The Basics
Kotlin: The Basics - Variable Declarations
Kotlin: The Basics - Function Declarations
Kotlin: The Basics - Class Declarations
Kotlin: The Cool Parts
Kotlin: The Cool Parts - Data Classes (http://bit.ly/2xhvVlh)
Kotlin: The Cool Parts - Elvis Operator
Kotlin: The Cool Parts - Extension Functions
Kotlin: The Cool Parts - Named and Default Arguments
Kotlin: The Cool Parts - When
Kotlin: The Cool Parts - Operator Overloading
Kotlin: The Cool Parts - Object Desctructuring
Kotlin: The Cool Parts - Custom Infix Operators
Kotlin: The Cool Parts - And Much More!
● Lambda functions
● Easier string interpolation
● Simplified getter/setter syntax
● Coroutines
● “Synthetic” plugin to replace findViewById (similar to Butterknife)
Converting Java to Kotlin
Converting Java to Kotlin - Using the Converter
Converting Java to Kotlin - Double Bangs
Converting Java to Kotlin - Companion Objects
Drawbacks To Kotlin
Drawbacks To Kotlin
● It’s new
○ Initial development with Kotlin will be slower
○ Code patterns/anti-patterns not fully flushed out yet
● Java has more robust static analysis tools
● Much smaller developer community than Java’s
● Adds ~727kB to the total size of your project
Over time the benefits
of using Kotlin will
continue to grow.
Give it a try!
Thank you!
Twitter: @adammagana
GitHub: @adammagana

Weitere ähnliche Inhalte

Was ist angesagt?

The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011
Andrey Breslav
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
Andrzej Sitek
 

Was ist angesagt? (20)

Kotlin - Better Java
Kotlin - Better JavaKotlin - Better Java
Kotlin - Better Java
 
Android 101 - Kotlin ( Future of Android Development)
Android 101 - Kotlin ( Future of Android Development)Android 101 - Kotlin ( Future of Android Development)
Android 101 - Kotlin ( Future of Android Development)
 
The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
A quick and fast intro to Kotlin
A quick and fast intro to Kotlin A quick and fast intro to Kotlin
A quick and fast intro to Kotlin
 
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
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?
 
Kotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language designKotlin: Challenges in JVM language design
Kotlin: Challenges in JVM language design
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011Kotlin Slides from Devoxx 2011
Kotlin Slides from Devoxx 2011
 
Taking Kotlin to production, Seriously
Taking Kotlin to production, SeriouslyTaking Kotlin to production, Seriously
Taking Kotlin to production, Seriously
 
Kotlin a problem solver - gdd extended pune
Kotlin   a problem solver - gdd extended puneKotlin   a problem solver - gdd extended pune
Kotlin a problem solver - gdd extended pune
 
Fall in love with Kotlin
Fall in love with KotlinFall in love with Kotlin
Fall in love with Kotlin
 
Swift and Kotlin Presentation
Swift and Kotlin PresentationSwift and Kotlin Presentation
Swift and Kotlin Presentation
 
Kotlin in action
Kotlin in actionKotlin in action
Kotlin in action
 
Kotlin cheat sheet by ekito
Kotlin cheat sheet by ekitoKotlin cheat sheet by ekito
Kotlin cheat sheet by ekito
 
Kotlin, smarter development for the jvm
Kotlin, smarter development for the jvmKotlin, smarter development for the jvm
Kotlin, smarter development for the jvm
 
Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017Develop your next app with kotlin @ AndroidMakersFr 2017
Develop your next app with kotlin @ AndroidMakersFr 2017
 
Kotlin
KotlinKotlin
Kotlin
 
From object oriented to functional domain modeling
From object oriented to functional domain modelingFrom object oriented to functional domain modeling
From object oriented to functional domain modeling
 
Kotlin intro
Kotlin introKotlin intro
Kotlin intro
 

Ähnlich wie Say Goodbye To Java: Getting Started With Kotlin For Android Development

Ähnlich wie Say Goodbye To Java: Getting Started With Kotlin For Android Development (20)

Kotlin for Android
Kotlin for AndroidKotlin for Android
Kotlin for Android
 
Learn Kotlin and Build Robust Android Apps with Bcoder.pdf
Learn Kotlin and Build Robust Android Apps with Bcoder.pdfLearn Kotlin and Build Robust Android Apps with Bcoder.pdf
Learn Kotlin and Build Robust Android Apps with Bcoder.pdf
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Why to Choose Kotlin in 2023 to Build Mobile Apps Faster?
Why to Choose Kotlin in 2023 to Build Mobile Apps Faster?Why to Choose Kotlin in 2023 to Build Mobile Apps Faster?
Why to Choose Kotlin in 2023 to Build Mobile Apps Faster?
 
Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?
 
Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
 
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...
 
Dev Catchup @ARQGroup
Dev Catchup @ARQGroupDev Catchup @ARQGroup
Dev Catchup @ARQGroup
 
Kotlin
KotlinKotlin
Kotlin
 
Kotlin vs Java: Choosing The Right Language
Kotlin vs Java: Choosing The Right LanguageKotlin vs Java: Choosing The Right Language
Kotlin vs Java: Choosing The Right Language
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
 
Kotlin App Development Tips.pdf
Kotlin App Development Tips.pdfKotlin App Development Tips.pdf
Kotlin App Development Tips.pdf
 
Desarrollo multiplataforma con kotlin | UPV 2018
Desarrollo multiplataforma con kotlin  | UPV 2018Desarrollo multiplataforma con kotlin  | UPV 2018
Desarrollo multiplataforma con kotlin | UPV 2018
 
Why You Should Go with Kotlin for Android App Development.pdf
Why You Should Go with Kotlin for Android App Development.pdfWhy You Should Go with Kotlin for Android App Development.pdf
Why You Should Go with Kotlin for Android App Development.pdf
 
What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.
 
8 Reasons to Pick Kotlin Over Java for Android Development.pptx
8 Reasons to Pick Kotlin Over Java for Android Development.pptx8 Reasons to Pick Kotlin Over Java for Android Development.pptx
8 Reasons to Pick Kotlin Over Java for Android Development.pptx
 
Kotlin vs Java-A Comparison for Application Development Projects.pdf
Kotlin vs Java-A Comparison for Application Development Projects.pdfKotlin vs Java-A Comparison for Application Development Projects.pdf
Kotlin vs Java-A Comparison for Application Development Projects.pdf
 
Kotlin vs Java | A Comparative Analysis | IDEA USHER
Kotlin vs Java | A Comparative Analysis | IDEA USHERKotlin vs Java | A Comparative Analysis | IDEA USHER
Kotlin vs Java | A Comparative Analysis | IDEA USHER
 
AOT(Ahead Of Time)
AOT(Ahead Of Time)AOT(Ahead Of Time)
AOT(Ahead Of Time)
 

Kürzlich hochgeladen

%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
chiefasafspells
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
shinachiaurasa2
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Medical / Health Care (+971588192166) Mifepristone and Misoprostol tablets 200mg
 

Kürzlich hochgeladen (20)

%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
Abortion Pills In Pretoria ](+27832195400*)[ 🏥 Women's Abortion Clinic In Pre...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 

Say Goodbye To Java: Getting Started With Kotlin For Android Development

  • 1. Say Goodbye to Java: Getting Started With Kotlin for Android Adam Magaña
  • 3. Introduction ● Adam Magaña ● Lead Mobile Engineer @ Drund ● Currently spending most of my development time working on our Android application.
  • 4. A Quick History of Kotlin
  • 5. A Quick History of Kotlin ● Created by JetBrains ○ Creator of IntelliJ, the IDE that powers Android Studio ● First release - July 2011 ● Latest release (1.1.3) - June 2017 ● Official endorsement by Google as first-class language - May 2017 ● 8,000+ total releases on GitHub
  • 6. “We believe Kotlin is an excellent fit for Android not only because it gives developers what they want, but also because it matches the spirit of Android.” - Google Developer Product Group
  • 8. Companies Using Kotlin ● Pinterest ● Netflix ● AWS ● Uber ● Square ● Trello
  • 9. 10% Reduction in total methods after converting Basecamp to Kotlin.
  • 10. 30% Reduction in total lines of code after converting Basecamp to Kotlin.
  • 12. “But I’m comfortable and experienced with Java.” ● That’s great! ● You ultimately have to use what you’re most comfortable with. ● BUT “give it 5 minutes” before reacting.
  • 13. “I don’t want to convert my entire codebase to a new language.” ● Kotlin can be any percentage of your project. ● Fully compatible with JDK 6. ● 100% interoperable with existing Java code.
  • 14. “I don’t need Kotlin’s special tools to get the job done.” ● An experienced developer absolutely doesn’t need Kotlin. ● Much can be accomplished with Java. ● BUT barring architectural/performance issues, why would you want to have less tools available to you?
  • 15. “I’m worried about the performance implications of using Kotlin.” ● Performance is as good as an equivalent Java application. ● Kotlin lambdas often run faster than the same code written in Java. ● Incremental project builds using Kotlin are usually faster.
  • 16. A Very Small Soapbox
  • 17. A Very Small Soapbox ● Don’t let anyone, myself included, make you feel inadequate for choosing a different programming language or platform than them. ● Will there be better alternatives to what you use? Yes. ● Does that mean the service you provide to your users is sub-par? No. ● Is it okay to have differing opinions about certain technologies? Absolutely. ● Important to be supportive.
  • 18. We’re all in this together.
  • 19. Setting Up Kotlin in Android Studio
  • 20. Setting Up Kotlin in Android Studio ● Extremely easy setup for both major versions of AS ● Plugin for AS 2.3.X ○ Preferences > Plugins > Install JetBrains Plugin ● Baked-in support in AS 3.0.0 (beta) ○ Also includes: ■ A new profiler tool ■ A network/request analyzer (!)
  • 21. Installing the plugin for AS 2.3.X
  • 23. Kotlin: The Basics - Variable Declarations
  • 24. Kotlin: The Basics - Function Declarations
  • 25. Kotlin: The Basics - Class Declarations
  • 27. Kotlin: The Cool Parts - Data Classes (http://bit.ly/2xhvVlh)
  • 28. Kotlin: The Cool Parts - Elvis Operator
  • 29. Kotlin: The Cool Parts - Extension Functions
  • 30. Kotlin: The Cool Parts - Named and Default Arguments
  • 31. Kotlin: The Cool Parts - When
  • 32. Kotlin: The Cool Parts - Operator Overloading
  • 33. Kotlin: The Cool Parts - Object Desctructuring
  • 34. Kotlin: The Cool Parts - Custom Infix Operators
  • 35. Kotlin: The Cool Parts - And Much More! ● Lambda functions ● Easier string interpolation ● Simplified getter/setter syntax ● Coroutines ● “Synthetic” plugin to replace findViewById (similar to Butterknife)
  • 37. Converting Java to Kotlin - Using the Converter
  • 38. Converting Java to Kotlin - Double Bangs
  • 39. Converting Java to Kotlin - Companion Objects
  • 41. Drawbacks To Kotlin ● It’s new ○ Initial development with Kotlin will be slower ○ Code patterns/anti-patterns not fully flushed out yet ● Java has more robust static analysis tools ● Much smaller developer community than Java’s ● Adds ~727kB to the total size of your project
  • 42. Over time the benefits of using Kotlin will continue to grow.
  • 43. Give it a try!

Hinweis der Redaktion

  1. Highly recommend the pinterest engineering blog for insights on how they use Kotlin
  2. Dan Kim, Basecamp, developer happiness Overheard Nick talk about Ruby Dan compares Kotlin it to the way people feel about Ruby
  3. Made for classes are strictly used as data containers.