Slide 1

Slide 1 text

Building Multiplatform Projects with Kotlin Sergey Ryabov

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

No content

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

No content

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

WRITE ONCE, RUN EVERYWHERE! © JAVA

Slide 8

Slide 8 text

Client Backend Models Business Logic Presenters Views Android

Slide 9

Slide 9 text

Client Backend Models Business Logic Presenters Views Android Client Backend Models Business Logic Presenters Views iOS Client Backend Models Business Logic Presenters Views Web Models Business Logic Backend

Slide 10

Slide 10 text

Client Backend Models Business Logic Presenters Views Android Client Backend Business Logic Presenters Views iOS Client Backend Business Logic Presenters Views Web Business Logic Backend

Slide 11

Slide 11 text

Client Backend Models Business Logic Presenters Views Android Client Backend Presenters Views iOS Client Backend Presenters Views Web Business Logic Backend

Slide 12

Slide 12 text

Client Backend Models Business Logic Presenters Views Android Client Backend Views iOS Client Backend Views Web Business Logic Backend

Slide 13

Slide 13 text

WHAT DO WE ALREADY HAVE FOR THAT?

Slide 14

Slide 14 text

• C++ WHAT DO WE ALREADY HAVE FOR THAT?

Slide 15

Slide 15 text

• C++ • J2ObjC + GWT WHAT DO WE ALREADY HAVE FOR THAT?

Slide 16

Slide 16 text

• C++ • J2ObjC + GWT • Xamarin WHAT DO WE ALREADY HAVE FOR THAT?

Slide 17

Slide 17 text

• C++ • J2ObjC + GWT • Xamarin • ReactNative / Flutter WHAT DO WE ALREADY HAVE FOR THAT?

Slide 18

Slide 18 text

MAJOR PROBLEMS

Slide 19

Slide 19 text

• Access to native APIs MAJOR PROBLEMS

Slide 20

Slide 20 text

• Access to native APIs • Latest SDK version support MAJOR PROBLEMS

Slide 21

Slide 21 text

• Access to native APIs • Latest SDK version support • Modern dev stack MAJOR PROBLEMS

Slide 22

Slide 22 text

• Access to native APIs • Latest SDK version support • Modern dev stack • Executable size MAJOR PROBLEMS

Slide 23

Slide 23 text

WHY KOTLIN?

Slide 24

Slide 24 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS WHY KOTLIN?

Slide 25

Slide 25 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS WHY KOTLIN?

Slide 26

Slide 26 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS Apr 2017 - Kotlin Native Tech Preview WHY KOTLIN?

Slide 27

Slide 27 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS Apr 2017 - Kotlin Native Tech Preview Nov 2017 - Kotlin Native 0.4: iOS support WHY KOTLIN?

Slide 28

Slide 28 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS Apr 2017 - Kotlin Native Tech Preview Nov 2017 - Kotlin Native 0.4: iOS support Nov 2017 - Kotlin 1.2: Multiplatform projects, JVM/JS support WHY KOTLIN?

Slide 29

Slide 29 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS Apr 2017 - Kotlin Native Tech Preview Nov 2017 - Kotlin Native 0.4: iOS support Nov 2017 - Kotlin 1.2: Multiplatform projects, JVM/JS support Feb 2018 - Kotlin Native 0.6: Multiplatform support WHY KOTLIN?

Slide 30

Slide 30 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS Apr 2017 - Kotlin Native Tech Preview Nov 2017 - Kotlin Native 0.4: iOS support Nov 2017 - Kotlin 1.2: Multiplatform projects, JVM/JS support Feb 2018 - Kotlin Native 0.6: Multiplatform support + transparent ObjC/Kotlin collection types interop WHY KOTLIN?

Slide 31

Slide 31 text

Feb 2016 - Kotlin 1.0: production JVM, experimental JS Mar 2017 - Kotlin 1.1: production JS Apr 2017 - Kotlin Native Tech Preview Nov 2017 - Kotlin Native 0.4: iOS support Nov 2017 - Kotlin 1.2: Multiplatform projects, JVM/JS support Feb 2018 - Kotlin Native 0.6: Multiplatform support + transparent ObjC/Kotlin collection types interop Jul 2018 - Kotlin Native 0.8: kotlin-stdlib sync with JVM/JS WHY KOTLIN?

Slide 32

Slide 32 text

WHY KOTLIN IS BETTER?

Slide 33

Slide 33 text

WHY KOTLIN IS BETTER? • Access to native APIs

Slide 34

Slide 34 text

WHY KOTLIN IS BETTER? • Access to native APIs • Latest SDK version support

Slide 35

Slide 35 text

WHY KOTLIN IS BETTER? • Access to native APIs • Latest SDK version support • Modern dev stack

Slide 36

Slide 36 text

WHY KOTLIN IS BETTER? • Access to native APIs • Latest SDK version support • Modern dev stack • Executable size

Slide 37

Slide 37 text

HOW DOES IT WORK IN KOTLIN?

Slide 38

Slide 38 text

• Gradle multimodule projects HOW DOES IT WORK IN KOTLIN?

Slide 39

Slide 39 text

• Gradle multimodule projects • Common HOW DOES IT WORK IN KOTLIN?

Slide 40

Slide 40 text

• Gradle multimodule projects • Common • Platform HOW DOES IT WORK IN KOTLIN?

Slide 41

Slide 41 text

• Gradle multimodule projects • Common • Platform • Regular
 HOW DOES IT WORK IN KOTLIN?

Slide 42

Slide 42 text

• Gradle multimodule projects • Common • Platform • Regular
 • Multiplatform headers & implementations HOW DOES IT WORK IN KOTLIN?

Slide 43

Slide 43 text

• Gradle multimodule projects • Common • Platform • Regular
 • Multiplatform headers & implementations • expect & actual HOW DOES IT WORK IN KOTLIN?

Slide 44

Slide 44 text

Models Presenters Business Logic Views Repository

Slide 45

Slide 45 text

Models Presenters Business Logic Views Repository

Slide 46

Slide 46 text

Models common Presenters Business Logic common-client Views Repository

Slide 47

Slide 47 text

Models common common-client Presenters Business Logic View Interfaces Repo Interfaces Repository Views

Slide 48

Slide 48 text

Models common common-client Presenters Business Logic View Interfaces Repo Interfaces JS Models common-js JVM Models common-jvm Repository Repository Views Views Views

Slide 49

Slide 49 text

Models common common-client Presenters Business Logic View Interfaces Repo Interfaces Repository Views client-js JS Models common-js JVM Models common-jvm Repository Views client-android Views

Slide 50

Slide 50 text

Models common common-client Presenters Business Logic View Interfaces Repo Interfaces Repository Views client-js Repository client-jvm JS Models common-js JVM Models common-jvm Views client-android Views client-desktop

Slide 51

Slide 51 text

Models common common-client Presenters Business Logic View Interfaces Repo Interfaces Repository Views client-js Repository client-jvm JS Models common-js JVM Models common-jvm backend Views client-android Views client-desktop

Slide 52

Slide 52 text

EXAMPLE: ANDROID APP + FIREFOX EXTENSION

Slide 53

Slide 53 text

EXAMPLE: ANDROID APP + FIREFOX EXTENSION http://jennift.com/dpical.html Original

Slide 54

Slide 54 text

EXAMPLE: ANDROID APP + FIREFOX EXTENSION http://jennift.com/dpical.html Original

Slide 55

Slide 55 text

Business Logic View Interfaces common android Views Views js EXAMPLE: ANDROID APP + FIREFOX EXTENSION Presenters

Slide 56

Slide 56 text

CAVEATS

Slide 57

Slide 57 text

• Drawbacks of the concept CAVEATS

Slide 58

Slide 58 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) CAVEATS

Slide 59

Slide 59 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 CAVEATS

Slide 60

Slide 60 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems CAVEATS

Slide 61

Slide 61 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems • Kotlin/JS CAVEATS

Slide 62

Slide 62 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems • Kotlin/JS • One output JS-file per module CAVEATS

Slide 63

Slide 63 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems • Kotlin/JS • One output JS-file per module • Manual setup for including libs in the output CAVEATS

Slide 64

Slide 64 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems • Kotlin/JS • One output JS-file per module • Manual setup for including libs in the output • Kotlin/Native CAVEATS

Slide 65

Slide 65 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems • Kotlin/JS • One output JS-file per module • Manual setup for including libs in the output • Kotlin/Native • Still experimental - some features are not supported CAVEATS

Slide 66

Slide 66 text

• Drawbacks of the concept • Lots of manual work for module configuration (KT-23930) • Several platform codebases can’t sit in one module (different SourceSets )
 • Every platform has its own problems • Kotlin/JS • One output JS-file per module • Manual setup for including libs in the output • Kotlin/Native • Still experimental - some features are not supported • No reuse for multiplatform (yet) CAVEATS

Slide 67

Slide 67 text

FUTURE PLANS

Slide 68

Slide 68 text

• Re-thinking Multimodule projects configuration FUTURE PLANS

Slide 69

Slide 69 text

• Re-thinking Multimodule projects configuration • Catching up Kotlin/Native with other platforms FUTURE PLANS

Slide 70

Slide 70 text

• Re-thinking Multimodule projects configuration • Catching up Kotlin/Native with other platforms • Increasing common libs count • kotlin.test • kotlinx.html • kotlinx.serialization • kotlinx.coroutines • kotlinx.io • SQLDelight • … FUTURE PLANS

Slide 71

Slide 71 text

PRODUCTION USAGE

Slide 72

Slide 72 text

• KotlinConf app (https://github.com/jetbrains/kotlinconf-app) PRODUCTION USAGE

Slide 73

Slide 73 text

• KotlinConf app (https://github.com/jetbrains/kotlinconf-app) • Droidcon NYC (Sessionize) app (https://github.com/touchlab/DroidconKotlin) PRODUCTION USAGE

Slide 74

Slide 74 text

• KotlinConf app (https://github.com/jetbrains/kotlinconf-app) • Droidcon NYC (Sessionize) app (https://github.com/touchlab/DroidconKotlin) • Revolut (in-progress) PRODUCTION USAGE

Slide 75

Slide 75 text

WRITE ONCE,.RUN EVERYWHERE

Slide 76

Slide 76 text

WRITE ONCE,.SHARE EVERYWHERE

Slide 77

Slide 77 text

• Create common business logic, not UI WRITE ONCE,.SHARE EVERYWHERE

Slide 78

Slide 78 text

• Create common business logic, not UI • Write every part of the app in one language (optional) WRITE ONCE,.SHARE EVERYWHERE

Slide 79

Slide 79 text

• Code from the talk https://goo.gl/VYgHmr • Serialization support for Kotlin/Native https://github.com/Kotlin/kotlinx.serialization/issues/86 • Channels support for Kotlin/Native https://github.com/Kotlin/kotlinx.coroutines/issues/462 • New Multiplatform configuration approach https://youtrack.jetbrains.com/issue/KT-23930 LINKS

Slide 80

Slide 80 text

Building Multiplatform Projects with Kotlin Sergey Ryabov @colriot