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
Kotlin for Android
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

PPTX
Introduction to Kotlin
PDF
Log cat kotlindsl
PPTX
The Pros and Cons of Kotlin Language for Android App Development
PPTX
Advance Android Application Development
PPTX
Why Kotlin?
PDF
Golang, Future of Programming Language.
PDF
The Ring programming language version 1.5.4 book - Part 5 of 185
PPTX
Kotlin – Alternative oder Ergänzung zu Java?
Introduction to Kotlin
Log cat kotlindsl
The Pros and Cons of Kotlin Language for Android App Development
Advance Android Application Development
Why Kotlin?
Golang, Future of Programming Language.
The Ring programming language version 1.5.4 book - Part 5 of 185
Kotlin – Alternative oder Ergänzung zu Java?

What's hot (20)

PDF
Developers’ mDay u Banjoj Luci - Duško Bajić, Kotlin User Group Bosnia – Kotl...
PDF
The Ring programming language version 1.5.1 book - Part 4 of 180
PDF
The Ring programming language version 1.5.3 book - Part 5 of 184
PDF
Scala ♥ Graal by Flavio Brasil
PDF
DevNight #1 (Kotlin) @ The Brick Space
PPTX
PDF
The Ring programming language version 1.10 book - Part 6 of 212
DOCX
Swift language seminar topic
PDF
The Ring programming language version 1.3 book - Part 4 of 88
PDF
The Ring programming language version 1.7 book - Part 6 of 196
PDF
Programming Project Part 6
PDF
The Ring programming language version 1.5.2 book - Part 5 of 181
PDF
Introductio to Docker Containers
PDF
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
PDF
Java Applications with Visual Studio
PDF
The Ring programming language version 1.4.1 book - Part 2 of 31
PDF
Smart Internationalization assistance and resource translation tools
PPTX
2014 austin-api-sdks-are-apis-too
PDF
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
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.3 book - Part 5 of 184
Scala ♥ Graal by Flavio Brasil
DevNight #1 (Kotlin) @ The Brick Space
The Ring programming language version 1.10 book - Part 6 of 212
Swift language seminar topic
The Ring programming language version 1.3 book - Part 4 of 88
The Ring programming language version 1.7 book - Part 6 of 196
Programming Project Part 6
The Ring programming language version 1.5.2 book - Part 5 of 181
Introductio to Docker Containers
Kotlin Tutorial for Beginners | Kotlin Android Tutorial | Edureka
Java Applications with Visual Studio
The Ring programming language version 1.4.1 book - Part 2 of 31
Smart Internationalization assistance and resource translation tools
2014 austin-api-sdks-are-apis-too
Highly Surmountable Challenges in Ruby+OMR JIT Compilation
Ad

Similar to Kotlin for Android (20)

PDF
Learn Kotlin and Build Robust Android Apps with Bcoder.pdf
PPTX
Why to Choose Kotlin in 2023 to Build Mobile Apps Faster?
PPTX
Android with kotlin course
PPTX
Android Development with Kotlin course
PDF
Why You Should Go with Kotlin for Android App Development.pdf
PDF
Kotlin App Development Tips.pdf
PDF
Java vs Kotlin_ Which is the Best for Android App Development.pdf
PDF
Kotlin vs Java: Choosing The Right Language
PPTX
Say Goodbye To Java: Getting Started With Kotlin For Android Development
PDF
What is Kotlin.pdf
PDF
Android with Kotlin Course - SkillIQ.pdf
PPTX
PPTX
Is kotlin better option for android app development
PDF
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
PPTX
Kotlin Overview
PDF
Android Study Jams- Hands on Experience!(Day 1)
PPTX
8 Reasons to Pick Kotlin Over Java for Android Development.pptx
PDF
Kotlin vs Java-A Comparison for Application Development Projects.pdf
PPTX
What's new with Kotlin - Google IO18' extended Covenant University.
Learn Kotlin and Build Robust Android Apps with Bcoder.pdf
Why to Choose Kotlin in 2023 to Build Mobile Apps Faster?
Android with kotlin course
Android Development with Kotlin course
Why You Should Go with Kotlin for Android App Development.pdf
Kotlin App Development Tips.pdf
Java vs Kotlin_ Which is the Best for Android App Development.pdf
Kotlin vs Java: Choosing The Right Language
Say Goodbye To Java: Getting Started With Kotlin For Android Development
What is Kotlin.pdf
Android with Kotlin Course - SkillIQ.pdf
Is kotlin better option for android app development
The Rise of Kotlin Ecosystem in the Android App Development Industry.pdf
Kotlin Overview
Android Study Jams- Hands on Experience!(Day 1)
8 Reasons to Pick Kotlin Over Java for Android Development.pptx
Kotlin vs Java-A Comparison for Application Development Projects.pdf
What's new with Kotlin - Google IO18' extended Covenant University.
Ad

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
How Creative Agencies Leverage Project Management Software.pdf
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
Design an Analysis of Algorithms II-SECS-1021-03
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PDF
medical staffing services at VALiNTRY
PDF
2025 Textile ERP Trends: SAP, Odoo & Oracle
PDF
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
PDF
Understanding Forklifts - TECH EHS Solution
PDF
AI in Product Development-omnex systems
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
Reimagine Home Health with the Power of Agentic AI​
PPTX
Transform Your Business with a Software ERP System
PDF
Digital Strategies for Manufacturing Companies
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
L1 - Introduction to python Backend.pptx
How Creative Agencies Leverage Project Management Software.pdf
Internet Downloader Manager (IDM) Crack 6.42 Build 41
Design an Analysis of Algorithms II-SECS-1021-03
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Adobe Illustrator 28.6 Crack My Vision of Vector Design
medical staffing services at VALiNTRY
2025 Textile ERP Trends: SAP, Odoo & Oracle
Audit Checklist Design Aligning with ISO, IATF, and Industry Standards — Omne...
Understanding Forklifts - TECH EHS Solution
AI in Product Development-omnex systems
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Softaken Excel to vCard Converter Software.pdf
Reimagine Home Health with the Power of Agentic AI​
Transform Your Business with a Software ERP System
Digital Strategies for Manufacturing Companies
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...

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.
  • 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