Slide 1

Slide 1 text

A Case for Kotlin In Vaadin }> @oluwasayo_
 @oluwasayo Sayo Oladeji

Slide 2

Slide 2 text

Sayo Oladeji Pro Tools @ Vaadin HQ Who am I?

Slide 3

Slide 3 text

Using Java 10?
 Who are you?

Slide 4

Slide 4 text

• This thing called Java • Improving it • Kotlin to the rescue Agenda

Slide 5

Slide 5 text

• Java - The Platform (JVM) • Java - The Language This thing called Java

Slide 6

Slide 6 text

• The Java Virtual Machine and its tooling ecosystem • Tested, trusted and supported on multiple platforms • Very versatile and successful • Held back by legacy baggage Java - The Platform

Slide 7

Slide 7 text

• Tightly coupled to Java, the platform • Good, old, well known, well tested • Fairly good but not excellent type system • Some not-so-great default behavior (e.g final vs non-final) Java - The Language

Slide 8

Slide 8 text

• Evolves very slowly • Lacks modern features like coroutines, pattern matching, etc • Held back by backward compatibility and legacy baggage Java - The Language

Slide 9

Slide 9 text

All these lead to complexity, verbosity, and… Java - The Language

Slide 10

Slide 10 text

Wait for it... Java - The Language

Slide 11

Slide 11 text

BUGS! Java - The Language

Slide 12

Slide 12 text

Google GCM Verbosity

Slide 13

Slide 13 text

Same code in Kotlin #FightForSimplicity

Slide 14

Slide 14 text

• Vaadin Notification • Vaadin Charts Confusion and Bugs

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

• Strange methods: Objects.requireNonNull, Collections.unmodifiableList, etc • Classes, classes, classes everywhere: Optional, BiFunction, Consumer, BiConsumer, TriConsumer, QuadConsumer!! • Many design patterns: singleton, builder, AbstractStaticFactoryProxyProxySingletonB uilder Improving Java

Slide 17

Slide 17 text

• Static analysis: FindBugs, Sonar, etc • Bytecode enhancements: Lombok, etc • New compilers: Eclipse compiler, etc • New JVM languages: Groovy, Scala, Clojure, Ceylon, etc Improving Java

Slide 18

Slide 18 text

• Clojure is a Lisp. Not a bad thing in itself but comes with everything that a lisp is. • Groovy is too flexible for its own good. • Scala is too complex for its own good. • Some of these languages introduce significant footprints and runtime overhead Other JVM Languages

Slide 19

Slide 19 text

What is Kotlin? Kotlin to the Rescue

Slide 20

Slide 20 text

• Designed from the ground up to be simple, flexible enough and powerful • Sensible default behaviors • The good path is usually the path of least resistance • High performance and negligible footprint because everything happens at compile time Kotlin to the Rescue

Slide 21

Slide 21 text

Artifact Size Kilobytes 0 2000 4000 6000 8000 Groovy (v2.4.15) Clojure (v1.9.0) Scala (v2.12.5) Kotlin (v1.2.31)

Slide 22

Slide 22 text

Artifact Size Kilobytes 0 700 1400 2100 2800 Guava (24.1-jre) Kotlin (v1.2.31)

Slide 23

Slide 23 text

• World class tooling support • Big support from Google, Spring, etc • Seamless Java inter-op • Very low entry barrier • Large and helpful community Kotlin to the Rescue

Slide 24

Slide 24 text

Community 16,682 members 43,323 followers 9,844 questions 9,700 readers

Slide 25

Slide 25 text

GitHub Stars Stars (thousands) 0 5 10 15 20 25 Ceylon Groovy Clojure Scala Kotlin

Slide 26

Slide 26 text

• Kotlin/Vaadin can be tested quickly and reliably with the Karibu browserless testing framework (developed by @MartinVysny) • Kotlin targets JS • Kotlin targets Android • Kotlin targets native platforms Additional Benefits

Slide 27

Slide 27 text

What does Kotlin look like?

Slide 28

Slide 28 text

What do I need to do in my project to start using Kotlin?

Slide 29

Slide 29 text

Converting Java to Kotlin Cmd + Opt + Shift + K

Slide 30

Slide 30 text

Looking Under the Hood You can view the generated bytecode or even decompile it to Java with a click in your IDE

Slide 31

Slide 31 text

Decompile to Java

Slide 32

Slide 32 text

No Language is Perfect • Java is not as bad as I might have made it seem • It has a very small surface area and is beginner friendly • It has a lot of tools and libs and resources • It is well tested and trusted • It is now expected to evolve a bit faster with the new release train model • Kotlin isn’t perfect either • Its strong emphasis on Java inter-op might have hindered it a bit • It presents an extra surface area in addition to Java’s • Its debatable whether one can learn to use it effectively as a first language without Java experience

Slide 33

Slide 33 text

Summary of Kotlin’s Offering • Superior development experience compared to Java • Expressive code where intent is not buried in boilerplate • Safety and less chances of bugs • Targets Java, JavaScript, Android and native backends • Easy to get started with • Supported by industry giants and a large community • Excellent Java inter-op • Low adoption risk • Fast and reliable browserless testing

Slide 34

Slide 34 text

“Life is great and everything will be okay” This is my case for Kotlin in Vaadin }>

Slide 35

Slide 35 text

Useful links https://kotlinlang.org https://kotlinlang.org/docs/ kotlin-docs.pdf https://kotlin.link https://kotlin.slack.com https://www.npmjs.com/package/ create-react-kotlin-app Introduction to Kotlin Coroutines (Roman Elizarov) Deep Dive into Coroutines on the JVM (Roman Elizarov) Bootiful Kotlin (Josh Long) The Case for Kotlin and Ceylon (Russel Winder) Life is Great and Everything Will be Okay, Kotlin is Here