SlideShare a Scribd company logo
Kotlin 1.2
Sharing Code Between Platforms
Kirill Rozov
Android Developer
Kotlin Achievements
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
• More than 17% projects in Android Studio 3.0
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
• More than 17% projects in Android Studio 3.0
• Support in Spring 5.0
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
• More than 17% projects in Android Studio 3.0
• Support in Spring 5.0
• Gradle Kotlin DSL
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
• More than 17% projects in Android Studio 3.0
• Support in Spring 5.0
• Gradle Kotlin DSL
• Fastest-growing and one of the least-disliked languages*
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
• More than 17% projects in Android Studio 3.0
• Support in Spring 5.0
• Gradle Kotlin DSL
• Fastest-growing and one of the least-disliked languages*
• Support of JVM, JS, Native**
* Based on information from Stackoverflow

** In development
Kotlin Achievements
• Official language on Android
• More than 17% projects in Android Studio 3.0
• Support in Spring 5.0
• Gradle Kotlin DSL
• Fastest-growing and one of the least-disliked languages*
• Support of JVM, JS, Native**
• Kotlin Conf
* Based on information from Stackoverflow

** In development
Kotlin Popularity
1.11.0
Language
syntax
Array literals
// Kotlin 1.1
@CacheConfig(cacheNames = arrayOf("books", "default"))
class BookRepository
Array literals
// Kotlin 1.1
@CacheConfig(cacheNames = arrayOf("books", "default"))
class BookRepository
The array literal syntax is constrained to annotation arguments
// Kotlin 1.2
@CacheConfig(cacheNames = ["books", “default"])
class BookRepository
lateinit
lateinit var lateinitVar: String
// ‘false’
println("isInitialized: " + this::lateinitVar.isInitialized)
lateinitVar = "value"
// ‘true’
println("isInitialized: " + this::lateinitVar.isInitialized)
lateinit
• Possibility to check whether lateinit variable is initialized
• Support on top-level properties
• Support for local variables
Inline functions
// Kotlin 1.1
fun <E> Iterable<E>.strings() = strings { it.toString() }
inline fun <E> Iterable<E>.strings(transform: (E) -> String) =
map { transform(it) }
Inline functions
// Kotlin 1.1
fun <E> Iterable<E>.strings() = strings { it.toString() }
inline fun <E> Iterable<E>.strings(transform: (E) -> String) =
map { transform(it) }
// Kotlin 1.2
inline fun <E> Iterable<E>.strings(
transform: (E) -> String = { it.toString() }) =
map { transform(it) }
Casts improvements
// Kotlin 1.1
val button = findViewById<View>(R.id.button) as Button
Casts improvements
// Kotlin 1.1
val button = findViewById<View>(R.id.button) as Button
// Kotlin 1.2
val button = findViewById(R.id.button) as Button
Casts improvements
// Kotlin 1.1
val s : Any = …
val firstChar = (s as? CharSequence)?.firstOrNull()
if (firstChar != null) {
s as CharSequence
return s.count { it == firstChar }
}
Casts improvements
// Kotlin 1.2
if (firstChar != null) {
// s: Any is smart cast to CharSequence
return s.count { it == firstChar }
}
// Kotlin 1.1
val s : Any = …
val firstChar = (s as? CharSequence)?.firstOrNull()
if (firstChar != null) {
s as CharSequence
return s.count { it == firstChar }
}
Standard
library
Standard library
Standard library
• Compatibility with Java 9 module system
Java 9 Support
• Compatible with the Java 9 module system (Project Jigsaw)

New artifacts kotlin-stdlib-jdkN
• Deprecated declaration in kotlin.reflect package were
removed

Use declarations in kotlin.reflect.full package instead
Standard library
• Compatibility with Java 9 module system
Standard library
• Compatibility with Java 9 module system
• New extensions for collections
chuncked, windowed, zipWithNext
val items = listOf(1, 1, 2, 3)
Only for Iterable<T>, Sequence<T>, CharSequence
chuncked, windowed, zipWithNext
val items = listOf(1, 1, 2, 3)
items.chunked(3) // [[1, 1, 2], [3]]
Only for Iterable<T>, Sequence<T>, CharSequence
chuncked, windowed, zipWithNext
val items = listOf(1, 1, 2, 3)
items.chunked(3) // [[1, 1, 2], [3]]
items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)]
Only for Iterable<T>, Sequence<T>, CharSequence
chuncked, windowed, zipWithNext
val items = listOf(1, 1, 2, 3)
items.chunked(3) // [[1, 1, 2], [3]]
items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)]
items.windowed(2) // [[1, 1], [1, 2], [2, 3]]
Only for Iterable<T>, Sequence<T>, CharSequence
chuncked, windowed, zipWithNext
val items = listOf(1, 1, 2, 3)
items.chunked(3) // [[1, 1, 2], [3]]
items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)]
items.windowed(2) // [[1, 1], [1, 2], [2, 3]]
items.windowed(2) { it.average() } // [1, 1.5, 2.5]
Only for Iterable<T>, Sequence<T>, CharSequence
chuncked, windowed, zipWithNext
val items = listOf(1, 1, 2, 3)
items.chunked(3) // [[1, 1, 2], [3]]
items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)]
items.windowed(2) // [[1, 1], [1, 2], [2, 3]]
items.windowed(2) { it.average() } // [1, 1.5, 2.5]
items.zipWithNext { a, b -> b - a } // [0, 1, 1]
Only for Iterable<T>, Sequence<T>, CharSequence
fill, replaceAll, shuffle
val items = mutableListOf(0, 1, 2, 3, 5, 8)
Only for MutableList<T>
fill, replaceAll, shuffle
val items = mutableListOf(0, 1, 2, 3, 5, 8)
items.shuffle() // [3, 8, 5, 0, 2, 1]. Output can be different
Only for MutableList<T>
fill, replaceAll, shuffle
val items = mutableListOf(0, 1, 2, 3, 5, 8)
items.shuffle() // [3, 8, 5, 0, 2, 1]. Output can be different
items.replaceAll { it * 2 } // [0, 2, 4, 6, 10, 16]
Only for MutableList<T>
fill, replaceAll, shuffle
val items = mutableListOf(0, 1, 2, 3, 5, 8)
items.shuffle() // [3, 8, 5, 0, 2, 1]. Output can be different
items.replaceAll { it * 2 } // [0, 2, 4, 6, 10, 16]
items.fill(5) // [5, 5, 5, 5, 5, 5]
Only for MutableList<T>
Standard library
• Fully compatibility with Java 9 module system
• New extensions for collections
Standard library
• Fully compatibility with Java 9 module system
• New extensions for collections
• Math operations
Standard library
• Fully compatibility with Java 9 module system
• New extensions for collections
• Math operations
• Operators and conversions for BigInteger and BigDecimal
• Floating point to bits conversions
• Regex is now Serializable
• Closeable.use() calls Throwable.addSuppressed() (JDK 7+)
Java
• Constructor calls normalization
• Java-default methods calls
• Breaking changes:
• Consistent behaviour of x.equals(null) for platform types
• Added check of receiver in inline extension functions that
were called on a null value of a platform type
• Smart cast inside try block after the block made more strict
Deprecation
• Mutating backing field of read-only property
• Override copy() in data classes
• Not inner classes in enum entries
• Passing a single item for a vararg parameter in the named
form
• Inner classes of generic classes extending Throwable
Other
• Support for ::foo as a shorthand for this::foo
• JS TypedArrays support for Kotlin primitive array (IntArray,
FloatArray, etc) enabled by default
• The Kotlin compiler now provides an option to treat all
warnings as errors
• Support in Kotlin Native 0.4
Compilation Performance
Approximately 25% improvement over Kotlin 1.1
Multiplatform

projects
Multiplatform Projects
expect & actual
// expected platform-specific API
expect fun hello(world: String) Common
// actual JVM implementation
actual fun hello(world: String) =
println(“Hello, $world, on the JVM!") JVM
// actual JS implementation
actual fun hello(world: String) =
console.log("Hello, $world, on the JS!") JS
expect class Date() {
fun getDate(): Int
fun getMonth(): Int
} Common
actual class Date {
private val calendar: Calendar
actual constructor() {
calendar = Calendar.getInstance()
}
actual fun getDate() = calendar[DAY_OF_MONTH]
actual fun getMonth() = calendar[MONTH]
} JVM
actual external class Date {
actual fun getDate(): Int
actual fun getMonth(): Int
} JS
Common

module
Platform

module
Regular

module
Common

module
JVM
JS
//common-jvm/build.gradle
apply plugin:'kotlin-platform-jvm'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
expectedBy project(":common")
} JVM
//android/build.gradle
apply plugin: 'kotlin-android'
dependencies {
implementation project(":common-jvm")
} Android
//common/build.gradle
apply plugin: 'kotlin-platform-common'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version"
}
Common
Common modules
• Test

Run test both on Java & JS platforms
• Serialization

Marshal Kotlin objects between different tiers of your application, based on JSON or ProtoBuf as
serialization format
• HTML

The same code to render HTML in the backend and in the frontend
Future commons
• IO
• Networking (HTTP, TCP, etc.)
• Dates
Summary
Summary
• Allow to write parts of app in same language
Summary
• Allow to write parts of app in same language
• Interoperability on supported platforms
Summary
• Allow to write parts of app in same language
• Interoperability on supported platforms
• Shared business logic
Summary
• Allow to write parts of app in same language
• Interoperability on supported platforms
• Shared business logic
• UI is platform-specific
Summary
• Allow to write parts of app in same language
• Interoperability on supported platforms
• Shared business logic
• UI is platform-specific
• JVM/JS code reuse already worked, Native coming soon
Summary
• Allow to write parts of app in same language
• Interoperability on supported platforms
• Shared business logic
• UI is platform-specific
• JVM/JS code reuse already worked, Native coming soon
• Support of Multiplatform projects in IDEA 2017.3
Thanks
krl.rozov@gmail.com

More Related Content

What's hot

[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史
[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史
[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史
Shengyou Fan
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Eugene Kurko
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpmsom_nangia
 
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
Shengyou Fan
 
運用 Exposed 管理及操作資料庫
運用 Exposed 管理及操作資料庫運用 Exposed 管理及操作資料庫
運用 Exposed 管理及操作資料庫
Shengyou Fan
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
jtyr
 
はじめてのSymfony2
はじめてのSymfony2はじめてのSymfony2
はじめてのSymfony2
Tomohiro MITSUMUNE
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparisonHiroshi Nakamura
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev ConfTom Croucher
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
Ismael Celis
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
kang taehun
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryTatsuhiko Miyagawa
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
Łukasz Proszek
 
Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}.toster
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化
Shengyou Fan
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
Fabio Akita
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with ComposerJason Grimes
 
Controlling multiple VMs with the power of Python
Controlling multiple VMs with the power of PythonControlling multiple VMs with the power of Python
Controlling multiple VMs with the power of Python
Yurii Vasylenko
 

What's hot (20)

[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史
[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史
[PHP 也有 Day] 垃圾留言守城記 - 用 Laravel 阻擋 SPAM 留言的奮鬥史
 
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
Multiplatform shared codebase with Kotlin/Native - UA Mobile 2019
 
Psgi Plack Sfpm
Psgi Plack SfpmPsgi Plack Sfpm
Psgi Plack Sfpm
 
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
[Kotlin Serverless 工作坊] 單元 4 - 實作 RSS Aggregator
 
運用 Exposed 管理及操作資料庫
運用 Exposed 管理及操作資料庫運用 Exposed 管理及操作資料庫
運用 Exposed 管理及操作資料庫
 
Automation and Ansible
Automation and AnsibleAutomation and Ansible
Automation and Ansible
 
はじめてのSymfony2
はじめてのSymfony2はじめてのSymfony2
はじめてのSymfony2
 
Ruby HTTP clients comparison
Ruby HTTP clients comparisonRuby HTTP clients comparison
Ruby HTTP clients comparison
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Using Node.js to  Build Great  Streaming Services - HTML5 Dev ConfUsing Node.js to  Build Great  Streaming Services - HTML5 Dev Conf
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
 
Node.js streaming csv downloads proxy
Node.js streaming csv downloads proxyNode.js streaming csv downloads proxy
Node.js streaming csv downloads proxy
 
Javascript asynchronous
Javascript asynchronousJavascript asynchronous
Javascript asynchronous
 
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
 
Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.Take control of your Jenkins jobs via job DSL.
Take control of your Jenkins jobs via job DSL.
 
Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}Matthew Eernisse, NodeJs, .toster {webdev}
Matthew Eernisse, NodeJs, .toster {webdev}
 
用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化用 OPENRNDR 將 Chatbot 訊息視覺化
用 OPENRNDR 將 Chatbot 訊息視覺化
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
 
Dependency management with Composer
Dependency management with ComposerDependency management with Composer
Dependency management with Composer
 
Wider than rails
Wider than railsWider than rails
Wider than rails
 
Tatsumaki
TatsumakiTatsumaki
Tatsumaki
 
Controlling multiple VMs with the power of Python
Controlling multiple VMs with the power of PythonControlling multiple VMs with the power of Python
Controlling multiple VMs with the power of Python
 

Similar to Kotlin 1.2: Sharing code between platforms

Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)
Cody Engel
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
Mohamed Nabil, MSc.
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
Oswald Campesato
 
Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
Stuart Roebuck
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
Davide Cerbo
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
TechMagic
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
Stuart Roebuck
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
Luke Donnet
 
Hello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebHello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC Unideb
Muhammad Raza
 
Building Mobile Apps with Android
Building Mobile Apps with AndroidBuilding Mobile Apps with Android
Building Mobile Apps with Android
Kurt Renzo Acosta
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
Pavlo Baron
 
Intro to Kotlin
Intro to KotlinIntro to Kotlin
Intro to Kotlin
Magda Miu
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
Robert Stern
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
Shem Magnezi
 
Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)
Gesh Markov
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
Christoph Pickl
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
Troy Miles
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
Tim Underwood
 

Similar to Kotlin 1.2: Sharing code between platforms (20)

Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)Privet Kotlin (Windy City DevFest)
Privet Kotlin (Windy City DevFest)
 
Kotlin for Android Developers - 3
Kotlin for Android Developers - 3Kotlin for Android Developers - 3
Kotlin for Android Developers - 3
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
Scala coated JVM
Scala coated JVMScala coated JVM
Scala coated JVM
 
Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)Kotlin: forse è la volta buona (Trento)
Kotlin: forse è la volta buona (Trento)
 
K is for Kotlin
K is for KotlinK is for Kotlin
K is for Kotlin
 
Scala @ TechMeetup Edinburgh
Scala @ TechMeetup EdinburghScala @ TechMeetup Edinburgh
Scala @ TechMeetup Edinburgh
 
Exploring Clojurescript
Exploring ClojurescriptExploring Clojurescript
Exploring Clojurescript
 
Hello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC UnidebHello kotlin | An Event by DSC Unideb
Hello kotlin | An Event by DSC Unideb
 
Building Mobile Apps with Android
Building Mobile Apps with AndroidBuilding Mobile Apps with Android
Building Mobile Apps with Android
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
Intro to Kotlin
Intro to KotlinIntro to Kotlin
Intro to Kotlin
 
Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1Golang basics for Java developers - Part 1
Golang basics for Java developers - Part 1
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Building android apps with kotlin
Building android apps with kotlinBuilding android apps with kotlin
Building android apps with kotlin
 
Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)Kotlin For Android - Functions (part 3 of 7)
Kotlin For Android - Functions (part 3 of 7)
 
Kotlin 101 for Java Developers
Kotlin 101 for Java DevelopersKotlin 101 for Java Developers
Kotlin 101 for Java Developers
 
React Development with the MERN Stack
React Development with the MERN StackReact Development with the MERN Stack
React Development with the MERN Stack
 
A Brief Intro to Scala
A Brief Intro to ScalaA Brief Intro to Scala
A Brief Intro to Scala
 

More from Kirill Rozov

Kotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is coming
Kirill Rozov
 
2 years without Java. Kotlin only
2 years without Java. Kotlin only2 years without Java. Kotlin only
2 years without Java. Kotlin only
Kirill Rozov
 
Почему Kotlin?
Почему Kotlin?Почему Kotlin?
Почему Kotlin?
Kirill Rozov
 
KOIN for dependency Injection
KOIN for dependency InjectionKOIN for dependency Injection
KOIN for dependency Injection
Kirill Rozov
 
Optimize APK size
Optimize APK sizeOptimize APK size
Optimize APK size
Kirill Rozov
 
ConstraintLayout. Fell the Power of constraints
ConstraintLayout. Fell the Power of constraintsConstraintLayout. Fell the Power of constraints
ConstraintLayout. Fell the Power of constraints
Kirill Rozov
 
Kotlin - следующий язык после Java
Kotlin - следующий язык после JavaKotlin - следующий язык после Java
Kotlin - следующий язык после Java
Kirill Rozov
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kirill Rozov
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kirill Rozov
 
Why Kotlin - Apalon Kotlin Sprint Part 1
Why Kotlin - Apalon Kotlin Sprint Part 1Why Kotlin - Apalon Kotlin Sprint Part 1
Why Kotlin - Apalon Kotlin Sprint Part 1
Kirill Rozov
 
Тестирование на Android с Dagger 2
Тестирование на Android с Dagger 2Тестирование на Android с Dagger 2
Тестирование на Android с Dagger 2
Kirill Rozov
 
Что нового в Android O (Grodno HTP)
Что нового в Android O (Grodno HTP)Что нового в Android O (Grodno HTP)
Что нового в Android O (Grodno HTP)
Kirill Rozov
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android O
Kirill Rozov
 
Android service
Android serviceAndroid service
Android service
Kirill Rozov
 
Effective Java
Effective JavaEffective Java
Effective Java
Kirill Rozov
 
Dagger 2
Dagger 2Dagger 2
Dagger 2
Kirill Rozov
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
Kirill Rozov
 
REST
RESTREST
Kotlin для Android
Kotlin для AndroidKotlin для Android
Kotlin для Android
Kirill Rozov
 
What's new in Android M
What's new in Android MWhat's new in Android M
What's new in Android M
Kirill Rozov
 

More from Kirill Rozov (20)

Kotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is comingKotlin Coroutines. Flow is coming
Kotlin Coroutines. Flow is coming
 
2 years without Java. Kotlin only
2 years without Java. Kotlin only2 years without Java. Kotlin only
2 years without Java. Kotlin only
 
Почему Kotlin?
Почему Kotlin?Почему Kotlin?
Почему Kotlin?
 
KOIN for dependency Injection
KOIN for dependency InjectionKOIN for dependency Injection
KOIN for dependency Injection
 
Optimize APK size
Optimize APK sizeOptimize APK size
Optimize APK size
 
ConstraintLayout. Fell the Power of constraints
ConstraintLayout. Fell the Power of constraintsConstraintLayout. Fell the Power of constraints
ConstraintLayout. Fell the Power of constraints
 
Kotlin - следующий язык после Java
Kotlin - следующий язык после JavaKotlin - следующий язык после Java
Kotlin - следующий язык после Java
 
Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3Kotlin Advanced - Apalon Kotlin Sprint Part 3
Kotlin Advanced - Apalon Kotlin Sprint Part 3
 
Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2Kotlin Basics - Apalon Kotlin Sprint Part 2
Kotlin Basics - Apalon Kotlin Sprint Part 2
 
Why Kotlin - Apalon Kotlin Sprint Part 1
Why Kotlin - Apalon Kotlin Sprint Part 1Why Kotlin - Apalon Kotlin Sprint Part 1
Why Kotlin - Apalon Kotlin Sprint Part 1
 
Тестирование на Android с Dagger 2
Тестирование на Android с Dagger 2Тестирование на Android с Dagger 2
Тестирование на Android с Dagger 2
 
Что нового в Android O (Grodno HTP)
Что нового в Android O (Grodno HTP)Что нового в Android O (Grodno HTP)
Что нового в Android O (Grodno HTP)
 
What's new in Android O
What's new in Android OWhat's new in Android O
What's new in Android O
 
Android service
Android serviceAndroid service
Android service
 
Effective Java
Effective JavaEffective Java
Effective Java
 
Dagger 2
Dagger 2Dagger 2
Dagger 2
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
REST
RESTREST
REST
 
Kotlin для Android
Kotlin для AndroidKotlin для Android
Kotlin для Android
 
What's new in Android M
What's new in Android MWhat's new in Android M
What's new in Android M
 

Recently uploaded

PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
bhadouriyakaku
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
insn4465
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
nikitacareer3
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
RicletoEspinosa1
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
Aditya Rajan Patra
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Soumen Santra
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
obonagu
 

Recently uploaded (20)

PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.pptPROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
PROJECT FORMAT FOR EVS AMITY UNIVERSITY GWALIOR.ppt
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
哪里办理(csu毕业证书)查尔斯特大学毕业证硕士学历原版一模一样
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptxTOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
TOP 10 B TECH COLLEGES IN JAIPUR 2024.pptx
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
AIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdfAIR POLLUTION lecture EnE203 updated.pdf
AIR POLLUTION lecture EnE203 updated.pdf
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
Recycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part IIIRecycled Concrete Aggregate in Construction Part III
Recycled Concrete Aggregate in Construction Part III
 
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTSHeap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
Heap Sort (SS).ppt FOR ENGINEERING GRADUATES, BCA, MCA, MTECH, BSC STUDENTS
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
原版制作(unimelb毕业证书)墨尔本大学毕业证Offer一模一样
 

Kotlin 1.2: Sharing code between platforms

  • 1. Kotlin 1.2 Sharing Code Between Platforms Kirill Rozov Android Developer
  • 2. Kotlin Achievements * Based on information from Stackoverflow
 ** In development
  • 3. Kotlin Achievements • Official language on Android * Based on information from Stackoverflow
 ** In development
  • 4. Kotlin Achievements • Official language on Android • More than 17% projects in Android Studio 3.0 * Based on information from Stackoverflow
 ** In development
  • 5. Kotlin Achievements • Official language on Android • More than 17% projects in Android Studio 3.0 • Support in Spring 5.0 * Based on information from Stackoverflow
 ** In development
  • 6. Kotlin Achievements • Official language on Android • More than 17% projects in Android Studio 3.0 • Support in Spring 5.0 • Gradle Kotlin DSL * Based on information from Stackoverflow
 ** In development
  • 7. Kotlin Achievements • Official language on Android • More than 17% projects in Android Studio 3.0 • Support in Spring 5.0 • Gradle Kotlin DSL • Fastest-growing and one of the least-disliked languages* * Based on information from Stackoverflow
 ** In development
  • 8. Kotlin Achievements • Official language on Android • More than 17% projects in Android Studio 3.0 • Support in Spring 5.0 • Gradle Kotlin DSL • Fastest-growing and one of the least-disliked languages* • Support of JVM, JS, Native** * Based on information from Stackoverflow
 ** In development
  • 9. Kotlin Achievements • Official language on Android • More than 17% projects in Android Studio 3.0 • Support in Spring 5.0 • Gradle Kotlin DSL • Fastest-growing and one of the least-disliked languages* • Support of JVM, JS, Native** • Kotlin Conf * Based on information from Stackoverflow
 ** In development
  • 12. Array literals // Kotlin 1.1 @CacheConfig(cacheNames = arrayOf("books", "default")) class BookRepository
  • 13. Array literals // Kotlin 1.1 @CacheConfig(cacheNames = arrayOf("books", "default")) class BookRepository The array literal syntax is constrained to annotation arguments // Kotlin 1.2 @CacheConfig(cacheNames = ["books", “default"]) class BookRepository
  • 14. lateinit lateinit var lateinitVar: String // ‘false’ println("isInitialized: " + this::lateinitVar.isInitialized) lateinitVar = "value" // ‘true’ println("isInitialized: " + this::lateinitVar.isInitialized)
  • 15. lateinit • Possibility to check whether lateinit variable is initialized • Support on top-level properties • Support for local variables
  • 16. Inline functions // Kotlin 1.1 fun <E> Iterable<E>.strings() = strings { it.toString() } inline fun <E> Iterable<E>.strings(transform: (E) -> String) = map { transform(it) }
  • 17. Inline functions // Kotlin 1.1 fun <E> Iterable<E>.strings() = strings { it.toString() } inline fun <E> Iterable<E>.strings(transform: (E) -> String) = map { transform(it) } // Kotlin 1.2 inline fun <E> Iterable<E>.strings( transform: (E) -> String = { it.toString() }) = map { transform(it) }
  • 18. Casts improvements // Kotlin 1.1 val button = findViewById<View>(R.id.button) as Button
  • 19. Casts improvements // Kotlin 1.1 val button = findViewById<View>(R.id.button) as Button // Kotlin 1.2 val button = findViewById(R.id.button) as Button
  • 20. Casts improvements // Kotlin 1.1 val s : Any = … val firstChar = (s as? CharSequence)?.firstOrNull() if (firstChar != null) { s as CharSequence return s.count { it == firstChar } }
  • 21. Casts improvements // Kotlin 1.2 if (firstChar != null) { // s: Any is smart cast to CharSequence return s.count { it == firstChar } } // Kotlin 1.1 val s : Any = … val firstChar = (s as? CharSequence)?.firstOrNull() if (firstChar != null) { s as CharSequence return s.count { it == firstChar } }
  • 24. Standard library • Compatibility with Java 9 module system
  • 25. Java 9 Support • Compatible with the Java 9 module system (Project Jigsaw)
 New artifacts kotlin-stdlib-jdkN • Deprecated declaration in kotlin.reflect package were removed
 Use declarations in kotlin.reflect.full package instead
  • 26. Standard library • Compatibility with Java 9 module system
  • 27. Standard library • Compatibility with Java 9 module system • New extensions for collections
  • 28. chuncked, windowed, zipWithNext val items = listOf(1, 1, 2, 3) Only for Iterable<T>, Sequence<T>, CharSequence
  • 29. chuncked, windowed, zipWithNext val items = listOf(1, 1, 2, 3) items.chunked(3) // [[1, 1, 2], [3]] Only for Iterable<T>, Sequence<T>, CharSequence
  • 30. chuncked, windowed, zipWithNext val items = listOf(1, 1, 2, 3) items.chunked(3) // [[1, 1, 2], [3]] items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)] Only for Iterable<T>, Sequence<T>, CharSequence
  • 31. chuncked, windowed, zipWithNext val items = listOf(1, 1, 2, 3) items.chunked(3) // [[1, 1, 2], [3]] items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)] items.windowed(2) // [[1, 1], [1, 2], [2, 3]] Only for Iterable<T>, Sequence<T>, CharSequence
  • 32. chuncked, windowed, zipWithNext val items = listOf(1, 1, 2, 3) items.chunked(3) // [[1, 1, 2], [3]] items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)] items.windowed(2) // [[1, 1], [1, 2], [2, 3]] items.windowed(2) { it.average() } // [1, 1.5, 2.5] Only for Iterable<T>, Sequence<T>, CharSequence
  • 33. chuncked, windowed, zipWithNext val items = listOf(1, 1, 2, 3) items.chunked(3) // [[1, 1, 2], [3]] items.chunked(2) { (x, y) -> Pair(x, y) } // [(1, 1), (2, 3)] items.windowed(2) // [[1, 1], [1, 2], [2, 3]] items.windowed(2) { it.average() } // [1, 1.5, 2.5] items.zipWithNext { a, b -> b - a } // [0, 1, 1] Only for Iterable<T>, Sequence<T>, CharSequence
  • 34. fill, replaceAll, shuffle val items = mutableListOf(0, 1, 2, 3, 5, 8) Only for MutableList<T>
  • 35. fill, replaceAll, shuffle val items = mutableListOf(0, 1, 2, 3, 5, 8) items.shuffle() // [3, 8, 5, 0, 2, 1]. Output can be different Only for MutableList<T>
  • 36. fill, replaceAll, shuffle val items = mutableListOf(0, 1, 2, 3, 5, 8) items.shuffle() // [3, 8, 5, 0, 2, 1]. Output can be different items.replaceAll { it * 2 } // [0, 2, 4, 6, 10, 16] Only for MutableList<T>
  • 37. fill, replaceAll, shuffle val items = mutableListOf(0, 1, 2, 3, 5, 8) items.shuffle() // [3, 8, 5, 0, 2, 1]. Output can be different items.replaceAll { it * 2 } // [0, 2, 4, 6, 10, 16] items.fill(5) // [5, 5, 5, 5, 5, 5] Only for MutableList<T>
  • 38. Standard library • Fully compatibility with Java 9 module system • New extensions for collections
  • 39. Standard library • Fully compatibility with Java 9 module system • New extensions for collections • Math operations
  • 40. Standard library • Fully compatibility with Java 9 module system • New extensions for collections • Math operations • Operators and conversions for BigInteger and BigDecimal • Floating point to bits conversions • Regex is now Serializable • Closeable.use() calls Throwable.addSuppressed() (JDK 7+)
  • 41. Java • Constructor calls normalization • Java-default methods calls • Breaking changes: • Consistent behaviour of x.equals(null) for platform types • Added check of receiver in inline extension functions that were called on a null value of a platform type • Smart cast inside try block after the block made more strict
  • 42. Deprecation • Mutating backing field of read-only property • Override copy() in data classes • Not inner classes in enum entries • Passing a single item for a vararg parameter in the named form • Inner classes of generic classes extending Throwable
  • 43. Other • Support for ::foo as a shorthand for this::foo • JS TypedArrays support for Kotlin primitive array (IntArray, FloatArray, etc) enabled by default • The Kotlin compiler now provides an option to treat all warnings as errors • Support in Kotlin Native 0.4
  • 44. Compilation Performance Approximately 25% improvement over Kotlin 1.1
  • 47. expect & actual // expected platform-specific API expect fun hello(world: String) Common // actual JVM implementation actual fun hello(world: String) = println(“Hello, $world, on the JVM!") JVM // actual JS implementation actual fun hello(world: String) = console.log("Hello, $world, on the JS!") JS
  • 48. expect class Date() { fun getDate(): Int fun getMonth(): Int } Common actual class Date { private val calendar: Calendar actual constructor() { calendar = Calendar.getInstance() } actual fun getDate() = calendar[DAY_OF_MONTH] actual fun getMonth() = calendar[MONTH] } JVM actual external class Date { actual fun getDate(): Int actual fun getMonth(): Int } JS
  • 51. //common-jvm/build.gradle apply plugin:'kotlin-platform-jvm' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" expectedBy project(":common") } JVM //android/build.gradle apply plugin: 'kotlin-android' dependencies { implementation project(":common-jvm") } Android //common/build.gradle apply plugin: 'kotlin-platform-common' dependencies { compile "org.jetbrains.kotlin:kotlin-stdlib-common:$kotlin_version" } Common
  • 52. Common modules • Test
 Run test both on Java & JS platforms • Serialization
 Marshal Kotlin objects between different tiers of your application, based on JSON or ProtoBuf as serialization format • HTML
 The same code to render HTML in the backend and in the frontend
  • 53. Future commons • IO • Networking (HTTP, TCP, etc.) • Dates
  • 55. Summary • Allow to write parts of app in same language
  • 56. Summary • Allow to write parts of app in same language • Interoperability on supported platforms
  • 57. Summary • Allow to write parts of app in same language • Interoperability on supported platforms • Shared business logic
  • 58. Summary • Allow to write parts of app in same language • Interoperability on supported platforms • Shared business logic • UI is platform-specific
  • 59. Summary • Allow to write parts of app in same language • Interoperability on supported platforms • Shared business logic • UI is platform-specific • JVM/JS code reuse already worked, Native coming soon
  • 60. Summary • Allow to write parts of app in same language • Interoperability on supported platforms • Shared business logic • UI is platform-specific • JVM/JS code reuse already worked, Native coming soon • Support of Multiplatform projects in IDEA 2017.3