SlideShare a Scribd company logo
Version 1.0
Kotlin for Android
Han Yin @ Jun, 2018
Modern. Expressive. Safe.
TOC
● Overview, Major advantages, Case study
● Language features by examples
● Migration advices, Tutorials, Documentations & Samples
Statically typed programming language for
modern multi-platform applications.
Overview
Overview: a brief history
2011
JetBrains unveiled Project Kotlin
A new language for the JVM, which had been under
development for a year.
2012
Open sourced under the Apache 2 license
JetBrains hopes that the new language will drive
IntelliJ IDEA sales.
2016
Kotlin v1.0 was released on February 15
This is considered to be the first officially stable
release and JetBrains has committed to long-term
backwards compatibility starting with this version.
2017
Google announced first-class support for
Kotlin on Android
Android ❤ Kotlin
2018
Kotlin v1.2 was released on November 28
Sharing Code between JVM and Javascript platforms
feature was newly added to this release.
Major advantages @ Language
1 Concise
Drastically reduce the amount of
boilerplate code.
2 Safe
Avoid entire classes of errors such as
null pointer exceptions.
3 Inter-operable
Leverage existing libraries for the JVM,
Android, and the browser.
4 Tool-friendly
Choose any Java IDE or build from the
command line.
Major advantages @ Android
1 Compatibility
Fully compatible with JDK 6 and Android
build system.
2 Performance
A Kotlin app runs as fast as an equivalent
Java one, due to similar bytecode structure.
3 Footprint
Kotlin has a very compact runtime
library, which can be further reduced
through the use of ProGuard.
4 Compilation Time
Incremental builds are usually as fast or
faster than with Java, due to efficient
incremental compilation.
Case study
1 Pinterest
Successfully introduced Kotlin into
their app, used by 150M people
every month.
2 Basecamp
100% Kotlin code. Reports a huge
difference in developer happiness,
great improvements in work quality
and speed.
Language features
Range expressions
String templates
Properties
Primary constructors
Data classes
First-class delegation
Companion objects
Singletons
Null-safety
Smart casts
Type inference
Type projections
Declaration-site variance
Separate interfaces for
read-only and mutable
collections
Operator overloading
Extension functions
Inline functions
Lambda expressions
* Coroutines
Java vs. Kotlin
100% interoperable with Java
● For a Java developer, getting started with
Kotlin is very easy. The automated Java to
Kotlin converter included in the Kotlin plugin
helps with the first steps.
● Kotlin Koans offer a guide through the key
features of the language with a series of
interactive exercises.
Null-safety, Mutable & Read-only variable:
Lateinit
Elvis operator
Conditional expressions & When expressions
Smart casts
For loops & Range expressions
Easy bundle: listOf, arrayOf, mapOf, setOf, etc.
Break, Continue & Return labels
Named arguments & Default arguments
Data classes, Parcelable
Properties & Fields
● To use a property, simply refer to it
by name, as if it were a field in Java.
● Fields cannot be declared directly in
Kotlin classes.
● However, when a property needs a
backing field, Kotlin provides it
automatically.
String templates
Singleton
Sealed class
Destructuring declarations
Destructuring for loops
Extend functionality without inheritance
Operator overloading
Type aliases
Lazy Evaluation
Higher-Order Functions & Lambdas
Filter
Map
Reduce
Performant custom control structures
Standard functions: run, with, let, also, apply
Finally, say goodbye to findViewById!
Android KTX
● Android KTX is a set of Kotlin extensions that is part of the Android Jetpack family.
● It optimizes Jetpack and Android platform APIs for Kotlin use, while doesn’t add any new features to
the existing Android APIs.
● The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant,
and idiomatic by leveraging Kotlin language features, such as:
○ Extension functions and properties
○ Lambdas
○ Named parameters and parameter default values
Migration advices and Materials
● Advice from Google
● Advice from Basecamp
Android Developers:
A gradual approach
1. Start by writing tests in Kotlin.
Tests are not bundled with your app during
packaging, they are a safe place to add Kotlin code.
2. Write new code in Kotlin.
Before converting existing Java code, try adding small
pieces of new Kotlin code like a small class or
top-level helper function.
3. Update existing code to Kotlin.
Consider extracting small bits of Java functionality
and converting to Kotlin classes and top-level
functions.
Kotlin fully supported
in Android Studio 3.0
and higher
Basecamp
01
1. Write real production code.
It’s something you can see working in your app right away
and it’s more fun! That feeling of accomplishment and
seeing something work shouldn’t be discounted —
it builds your confidence and keeps you motivated.
2. Don’t try to learn the whole language at once
Find a few key concepts that click in your brain (not what
others tell you are the best parts of the language).
Focus just on those concepts and practice using them to
their fullest, without feeling overwhelmed.
Basecamp
02
3. Question all your Java habits
Regularly question whether you are doing something the
“Kotlin way”. When you see code that feels long or
complicated, pause and take another look at it.
4. Use cool downs for Kotlin
A great time to work on Kotlin conversions is when you’re
cooling down off a big release and watching for stability
and customer issues.
5. Learn from the auto converter
Auto convert the class, but keep the Java class handy. Put
them side by side, and see how the Kotlin compares.
Tutorials
0
1
How to Kotlin
From the Lead Kotlin Language Designer
(Google I/O '18)
0
2
Jake Wharton’s talk about Kotlin
for Android.
From Android KW December 2015 hosted by
Matthew P.
0
3
#31DaysOfKotlin
From Android Developer Advocates Florina
Muntenescu and Sean McQuillan
Documentations &
Samples
Kotlin is an open source language with its own
documentation and community:
01 | Get Started with Kotlin on Android
02 | Add Kotlin code
03 | Android Kotlin sample apps
04 | Getting started with Android and Kotlin
05 | Kotlin Koans Online
06 | Udacity Kotlin Bootcamp for Programmers
Thank you!

More Related Content

What's hot

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
 
The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180
Mahmoud Samir Fayed
 
Kotlin
KotlinKotlin
The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184
Mahmoud Samir Fayed
 
Scala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio BrasilScala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio Brasil
scalaconfjp
 
DevNight #1 (Kotlin) @ The Brick Space
DevNight #1 (Kotlin) @ The Brick SpaceDevNight #1 (Kotlin) @ The Brick Space
DevNight #1 (Kotlin) @ The Brick Space
Jedsada Tiwongvokul
 
The Ring programming language version 1.10 book - Part 6 of 212
The Ring programming language version 1.10 book - Part 6 of 212The Ring programming language version 1.10 book - Part 6 of 212
The Ring programming language version 1.10 book - Part 6 of 212
Mahmoud Samir Fayed
 
Swift language seminar topic
Swift language seminar topicSwift language seminar topic
Swift language seminar topic
Hyacinth Okeke
 
The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.3 book - Part 4 of 88The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.3 book - Part 4 of 88
Mahmoud Samir Fayed
 
The Ring programming language version 1.7 book - Part 6 of 196
The Ring programming language version 1.7 book - Part 6 of 196The Ring programming language version 1.7 book - Part 6 of 196
The Ring programming language version 1.7 book - Part 6 of 196
Mahmoud Samir Fayed
 
Programming Project Part 6
Programming Project Part 6Programming Project Part 6
Programming Project Part 6Bobby Billings
 
The Ring programming language version 1.5.2 book - Part 5 of 181
The Ring programming language version 1.5.2 book - Part 5 of 181The Ring programming language version 1.5.2 book - Part 5 of 181
The Ring programming language version 1.5.2 book - Part 5 of 181
Mahmoud Samir Fayed
 
Introductio to Docker Containers
Introductio to Docker ContainersIntroductio to Docker Containers
Introductio to Docker Containers
Houssein Ben Amor
 
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | EdurekaKotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Edureka!
 
Java Applications with Visual Studio
Java Applications with Visual StudioJava Applications with Visual Studio
Java Applications with Visual Studio
Red Hat Developers
 
The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31
Mahmoud Samir Fayed
 
Smart Internationalization assistance and resource translation tools
Smart Internationalization assistance and resource translation toolsSmart Internationalization assistance and resource translation tools
Smart Internationalization assistance and resource translation tools
mreiterer
 
2014 austin-api-sdks-are-apis-too
2014 austin-api-sdks-are-apis-too2014 austin-api-sdks-are-apis-too
2014 austin-api-sdks-are-apis-too
Jeff Brateman
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Matthew Gaudet
 

What's hot (20)

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...
 
The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180The Ring programming language version 1.5.1 book - Part 4 of 180
The Ring programming language version 1.5.1 book - Part 4 of 180
 
Kotlin
KotlinKotlin
Kotlin
 
The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184The Ring programming language version 1.5.3 book - Part 5 of 184
The Ring programming language version 1.5.3 book - Part 5 of 184
 
Scala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio BrasilScala ♥ Graal by Flavio Brasil
Scala ♥ Graal by Flavio Brasil
 
DevNight #1 (Kotlin) @ The Brick Space
DevNight #1 (Kotlin) @ The Brick SpaceDevNight #1 (Kotlin) @ The Brick Space
DevNight #1 (Kotlin) @ The Brick Space
 
D8 Dexer
D8 Dexer D8 Dexer
D8 Dexer
 
The Ring programming language version 1.10 book - Part 6 of 212
The Ring programming language version 1.10 book - Part 6 of 212The Ring programming language version 1.10 book - Part 6 of 212
The Ring programming language version 1.10 book - Part 6 of 212
 
Swift language seminar topic
Swift language seminar topicSwift language seminar topic
Swift language seminar topic
 
The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.3 book - Part 4 of 88The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.3 book - Part 4 of 88
 
The Ring programming language version 1.7 book - Part 6 of 196
The Ring programming language version 1.7 book - Part 6 of 196The Ring programming language version 1.7 book - Part 6 of 196
The Ring programming language version 1.7 book - Part 6 of 196
 
Programming Project Part 6
Programming Project Part 6Programming Project Part 6
Programming Project Part 6
 
The Ring programming language version 1.5.2 book - Part 5 of 181
The Ring programming language version 1.5.2 book - Part 5 of 181The Ring programming language version 1.5.2 book - Part 5 of 181
The Ring programming language version 1.5.2 book - Part 5 of 181
 
Introductio to Docker Containers
Introductio to Docker ContainersIntroductio to Docker Containers
Introductio to Docker Containers
 
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | EdurekaKotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
 
Java Applications with Visual Studio
Java Applications with Visual StudioJava Applications with Visual Studio
Java Applications with Visual Studio
 
The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31The Ring programming language version 1.4.1 book - Part 2 of 31
The Ring programming language version 1.4.1 book - Part 2 of 31
 
Smart Internationalization assistance and resource translation tools
Smart Internationalization assistance and resource translation toolsSmart Internationalization assistance and resource translation tools
Smart Internationalization assistance and resource translation tools
 
2014 austin-api-sdks-are-apis-too
2014 austin-api-sdks-are-apis-too2014 austin-api-sdks-are-apis-too
2014 austin-api-sdks-are-apis-too
 
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT CompilationHighly Surmountable Challenges in Ruby+OMR JIT Compilation
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
 

Similar to Kotlin for Android

Kotlin
KotlinKotlin
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
Bcoder Dev
 
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?
9 series
 
Android Development with Kotlin course
Android Development  with Kotlin courseAndroid Development  with Kotlin course
Android Development with Kotlin course
GoogleDevelopersLeba
 
Android with kotlin course
Android with kotlin courseAndroid with kotlin course
Android with kotlin course
Abdul Rahman Masri Attal
 
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
RipenApps
 
Kotlin App Development Tips.pdf
Kotlin App Development Tips.pdfKotlin App Development Tips.pdf
Kotlin App Development Tips.pdf
Marie Weaver
 
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
FredReynolds2
 
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
 
What is Kotlin.pdf
What is Kotlin.pdfWhat is Kotlin.pdf
What is Kotlin.pdf
SudhanshiBakre1
 
Android with Kotlin Course - SkillIQ.pdf
Android with Kotlin Course - SkillIQ.pdfAndroid with Kotlin Course - SkillIQ.pdf
Android with Kotlin Course - SkillIQ.pdf
SkilliQCourse
 
Kotlin
KotlinKotlin
Is kotlin better option for android app development
Is kotlin better option for android app development Is kotlin better option for android app development
Is kotlin better option for android app development
Concetto Labs
 
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdfThe Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
AppSquadz3
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
Ekta Raj
 
Android Study Jams- Hands on Experience!(Day 1)
Android Study Jams- Hands on Experience!(Day 1)Android Study Jams- Hands on Experience!(Day 1)
Android Study Jams- Hands on Experience!(Day 1)
GoogleDSC
 
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
Elsner Technologies Pvt. Ltd.
 
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
Techugo
 
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.
SimileoluwaAluko
 
Why Use Kotlin for Android App Development-Here’s a Guide.pdf
Why Use Kotlin for Android App Development-Here’s a Guide.pdfWhy Use Kotlin for Android App Development-Here’s a Guide.pdf
Why Use Kotlin for Android App Development-Here’s a Guide.pdf
Techugo
 

Similar to Kotlin for Android (20)

Kotlin
KotlinKotlin
Kotlin
 
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
 
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?
 
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
 
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
 
Kotlin App Development Tips.pdf
Kotlin App Development Tips.pdfKotlin App Development Tips.pdf
Kotlin App Development Tips.pdf
 
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
 
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
 
What is Kotlin.pdf
What is Kotlin.pdfWhat is Kotlin.pdf
What is Kotlin.pdf
 
Android with Kotlin Course - SkillIQ.pdf
Android with Kotlin Course - SkillIQ.pdfAndroid with Kotlin Course - SkillIQ.pdf
Android with Kotlin Course - SkillIQ.pdf
 
Kotlin
KotlinKotlin
Kotlin
 
Is kotlin better option for android app development
Is kotlin better option for android app development Is kotlin better option for android app development
Is kotlin better option for android app development
 
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdfThe Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
 
Kotlin Overview
Kotlin OverviewKotlin Overview
Kotlin Overview
 
Android Study Jams- Hands on Experience!(Day 1)
Android Study Jams- Hands on Experience!(Day 1)Android Study Jams- Hands on Experience!(Day 1)
Android Study Jams- Hands on Experience!(Day 1)
 
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
 
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.
 
Why Use Kotlin for Android App Development-Here’s a Guide.pdf
Why Use Kotlin for Android App Development-Here’s a Guide.pdfWhy Use Kotlin for Android App Development-Here’s a Guide.pdf
Why Use Kotlin for Android App Development-Here’s a Guide.pdf
 

Recently uploaded

A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
Philip Schwarz
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Anthony Dahanne
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Mind IT Systems
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
takuyayamamoto1800
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
e20449
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Globus
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
Globus
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
Max Andersen
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
Fermin Galan
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
Adele Miller
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Natan Silnitsky
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
Google
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
Cyanic lab
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
NYGGS Automation Suite
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
kalichargn70th171
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
Ortus Solutions, Corp
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
Georgi Kodinov
 

Recently uploaded (20)

A Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of PassageA Sighting of filterA in Typelevel Rite of Passage
A Sighting of filterA in Typelevel Rite of Passage
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
Custom Healthcare Software for Managing Chronic Conditions and Remote Patient...
 
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoamOpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
OpenFOAM solver for Helmholtz equation, helmholtzFoam / helmholtzBubbleFoam
 
Graphic Design Crash Course for beginners
Graphic Design Crash Course for beginnersGraphic Design Crash Course for beginners
Graphic Design Crash Course for beginners
 
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
Climate Science Flows: Enabling Petabyte-Scale Climate Analysis with the Eart...
 
Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus Compute wth IRI Workflows - GlobusWorld 2024
Globus Compute wth IRI Workflows - GlobusWorld 2024
 
First Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User EndpointsFirst Steps with Globus Compute Multi-User Endpoints
First Steps with Globus Compute Multi-User Endpoints
 
Quarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden ExtensionsQuarkus Hidden and Forbidden Extensions
Quarkus Hidden and Forbidden Extensions
 
Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604Orion Context Broker introduction 20240604
Orion Context Broker introduction 20240604
 
Vitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume MontevideoVitthal Shirke Microservices Resume Montevideo
Vitthal Shirke Microservices Resume Montevideo
 
May Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdfMay Marketo Masterclass, London MUG May 22 2024.pdf
May Marketo Masterclass, London MUG May 22 2024.pdf
 
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.ILBeyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
Beyond Event Sourcing - Embracing CRUD for Wix Platform - Java.IL
 
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteAI Pilot Review: The World’s First Virtual Assistant Marketing Suite
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
 
Cyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdfCyaniclab : Software Development Agency Portfolio.pdf
Cyaniclab : Software Development Agency Portfolio.pdf
 
Enterprise Resource Planning System in Telangana
Enterprise Resource Planning System in TelanganaEnterprise Resource Planning System in Telangana
Enterprise Resource Planning System in Telangana
 
A Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdfA Comprehensive Look at Generative AI in Retail App Testing.pdf
A Comprehensive Look at Generative AI in Retail App Testing.pdf
 
BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024BoxLang: Review our Visionary Licenses of 2024
BoxLang: Review our Visionary Licenses of 2024
 
Prosigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns: Transforming Business with Tailored Technology Solutions
Prosigns: Transforming Business with Tailored Technology Solutions
 
2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx2024 RoOUG Security model for the cloud.pptx
2024 RoOUG Security model for the cloud.pptx
 

Kotlin for Android

  • 1. Version 1.0 Kotlin for Android Han Yin @ Jun, 2018 Modern. Expressive. Safe.
  • 2. TOC ● Overview, Major advantages, Case study ● Language features by examples ● Migration advices, Tutorials, Documentations & Samples
  • 3. Statically typed programming language for modern multi-platform applications. Overview
  • 4. Overview: a brief history 2011 JetBrains unveiled Project Kotlin A new language for the JVM, which had been under development for a year. 2012 Open sourced under the Apache 2 license JetBrains hopes that the new language will drive IntelliJ IDEA sales. 2016 Kotlin v1.0 was released on February 15 This is considered to be the first officially stable release and JetBrains has committed to long-term backwards compatibility starting with this version. 2017 Google announced first-class support for Kotlin on Android Android ❤ Kotlin 2018 Kotlin v1.2 was released on November 28 Sharing Code between JVM and Javascript platforms feature was newly added to this release.
  • 5. Major advantages @ Language 1 Concise Drastically reduce the amount of boilerplate code. 2 Safe Avoid entire classes of errors such as null pointer exceptions. 3 Inter-operable Leverage existing libraries for the JVM, Android, and the browser. 4 Tool-friendly Choose any Java IDE or build from the command line.
  • 6. Major advantages @ Android 1 Compatibility Fully compatible with JDK 6 and Android build system. 2 Performance A Kotlin app runs as fast as an equivalent Java one, due to similar bytecode structure. 3 Footprint Kotlin has a very compact runtime library, which can be further reduced through the use of ProGuard. 4 Compilation Time Incremental builds are usually as fast or faster than with Java, due to efficient incremental compilation.
  • 7. Case study 1 Pinterest Successfully introduced Kotlin into their app, used by 150M people every month. 2 Basecamp 100% Kotlin code. Reports a huge difference in developer happiness, great improvements in work quality and speed.
  • 8. Language features Range expressions String templates Properties Primary constructors Data classes First-class delegation Companion objects Singletons Null-safety Smart casts Type inference Type projections Declaration-site variance Separate interfaces for read-only and mutable collections Operator overloading Extension functions Inline functions Lambda expressions * Coroutines
  • 10. 100% interoperable with Java ● For a Java developer, getting started with Kotlin is very easy. The automated Java to Kotlin converter included in the Kotlin plugin helps with the first steps. ● Kotlin Koans offer a guide through the key features of the language with a series of interactive exercises.
  • 11. Null-safety, Mutable & Read-only variable:
  • 14. Conditional expressions & When expressions
  • 16. For loops & Range expressions
  • 17. Easy bundle: listOf, arrayOf, mapOf, setOf, etc.
  • 18. Break, Continue & Return labels
  • 19. Named arguments & Default arguments
  • 21. Properties & Fields ● To use a property, simply refer to it by name, as if it were a field in Java. ● Fields cannot be declared directly in Kotlin classes. ● However, when a property needs a backing field, Kotlin provides it automatically.
  • 32.
  • 34. Map
  • 37. Standard functions: run, with, let, also, apply
  • 38. Finally, say goodbye to findViewById!
  • 39. Android KTX ● Android KTX is a set of Kotlin extensions that is part of the Android Jetpack family. ● It optimizes Jetpack and Android platform APIs for Kotlin use, while doesn’t add any new features to the existing Android APIs. ● The purpose of Android KTX is to make Android development with Kotlin more concise, pleasant, and idiomatic by leveraging Kotlin language features, such as: ○ Extension functions and properties ○ Lambdas ○ Named parameters and parameter default values
  • 40. Migration advices and Materials ● Advice from Google ● Advice from Basecamp
  • 41. Android Developers: A gradual approach 1. Start by writing tests in Kotlin. Tests are not bundled with your app during packaging, they are a safe place to add Kotlin code. 2. Write new code in Kotlin. Before converting existing Java code, try adding small pieces of new Kotlin code like a small class or top-level helper function. 3. Update existing code to Kotlin. Consider extracting small bits of Java functionality and converting to Kotlin classes and top-level functions. Kotlin fully supported in Android Studio 3.0 and higher
  • 42. Basecamp 01 1. Write real production code. It’s something you can see working in your app right away and it’s more fun! That feeling of accomplishment and seeing something work shouldn’t be discounted — it builds your confidence and keeps you motivated. 2. Don’t try to learn the whole language at once Find a few key concepts that click in your brain (not what others tell you are the best parts of the language). Focus just on those concepts and practice using them to their fullest, without feeling overwhelmed.
  • 43. Basecamp 02 3. Question all your Java habits Regularly question whether you are doing something the “Kotlin way”. When you see code that feels long or complicated, pause and take another look at it. 4. Use cool downs for Kotlin A great time to work on Kotlin conversions is when you’re cooling down off a big release and watching for stability and customer issues. 5. Learn from the auto converter Auto convert the class, but keep the Java class handy. Put them side by side, and see how the Kotlin compares.
  • 44. Tutorials 0 1 How to Kotlin From the Lead Kotlin Language Designer (Google I/O '18) 0 2 Jake Wharton’s talk about Kotlin for Android. From Android KW December 2015 hosted by Matthew P. 0 3 #31DaysOfKotlin From Android Developer Advocates Florina Muntenescu and Sean McQuillan
  • 45. Documentations & Samples Kotlin is an open source language with its own documentation and community: 01 | Get Started with Kotlin on Android 02 | Add Kotlin code 03 | Android Kotlin sample apps 04 | Getting started with Android and Kotlin 05 | Kotlin Koans Online 06 | Udacity Kotlin Bootcamp for Programmers