A Seamless Journey into the Awesome World of

Tom Hanley
Senior Software Engineer @
Organiser of the Dublin Kotlin User Group
Huge fan of Kotlin





In the beginning...
- I was a Java developer
- Java 8
- Big fan of functional programming
- Met a friend at a Dublin Java User Group meetup
Shortly after...
-
I started looking into Kotlin
-
Youtube "Kotlin for Java Programmers" by Venkat Subramaniam
- "The took Java and decided to add all the good features they could find, and then they called it Kotlin"
- "Fluent, elegant syntax"
- "Wonderful features from a lot of different languages"
- "A dream come true"
Kotlin History
- Started in 2010 by JetBrains
- They had a huge Java codebase
- Wanted a modern expressive language
- None of the existing languages were a good fit

Kotlin Design Goals
- 100% Java Interoperability
- More readable than Java
- Less error prone than Java
- More productive than Java
- Way simpler than Scala
- Pragmatic
- Not a research project
- No ground breaking features
- Best features established in other languages: groovy, scala, c#
Some time later...
- I started working in Toast!
-
Guest and restaurant-facing Android tablets
- Java & Kotlin
-
Backend services
- Java 8 Dropwizard Services
- Kotlin being used as well
-
Internal, guest-facing and restaurant-facing web apps
- Play monolith -> Angular/React
Not long after...
- I was working on the receipts team.
- Printed receipts (mobile)
- Digital receipts (web)
- 1.3 million receipts a day
- Refactoring project to extract and rewrite all this code to a shared library.
- This was all Java
Android Restrictions
- We're restricted to Java 7 on android?
- I can't use Java 8 streams?
- This sucks.
- Ok, I guess you can use guavas FluentIterable and RetroLambda, but they're far from elegant
- Hold on a second, theres no group by operator in guava?
- I saw some Kotlin somewhere in the mobile app, that means I can convert this all to Kotlin, right?
That weekend...
- I converted everything to Kotlin
- Turns out this is super easy
- Intellij really helps you along
-
Great functional programming features
- Beautiful streams library
- Immutability is the default
- Final is the default
- I showed the team some before and after highlights
- Kotlin sells itself
But how does all this modern streams stuff work on Java 7 restricted android devices?
-
Turns out the Kotlin compiler is awesome!
-
Kotlin can be compiled to any Java version bytecode
-
Kotlin can even be compiled to Javascript
-
Kotlin can even be compiled to native binaries for iOS, OSX, Windows, Linux etc.
-
What if the code isn't as performant as Java?
- Not a problem!
- Kotlin and Java can live side by side
- Java can call Kotlin, Kotlin can call Java, SEAMLESS
- If you find a place where Java is faster, write it in Java
What about the additional cognitive load to learn a new language?
- Its super easy to get up and running
- Its designed for Java developers
- Its a simpler and safer language than Java
- Its more readable, and more productive than Java
For a much more detailed argument for Kotlin see:
Doc by Jake Wharton
Full steam ahead with Kotlin!
Getting started
- Intellij auto-convert to Kotlin
- Really helps that Jetbrains created Intellij and Kotlin
- Caveat: you need to be careful with nullability
-
Writing Java in Kotlin
-
Which is fine
-
Gradually learn more idomatic Kotlin
-
-
Discover the std lib tools with autocomplete
- Quickly learn that the stdlib is fantastic
- Google "is there a more Kotlin way to do this"
- The online documentation is great

val myString: String? = null
println(myString.isNullOrEmpty()) // prints true!Discovering awesome features


- Covers all of the language features really well and in a lot of depth
- Written by two members of the Kotlin team
- Svetlana Isakova & Dimitri Jemerov
- Big chunks of this book obviated by Kotlin features
Let's get everyone using Kotlin!
Lets organise a series of meetups!
- We'll ramp up people in the office, and engage with the community in Dublin
- Beginner friendly, every 2 weeks
- Start from zero, ramp up, and dive into a fun project
Kotlin Koans
-
A series of exercises to get you familiar with the Kotlin syntax and features
-
The best way to learn all the language features
-
Written by Svetlana Isakova
-
Also wrote Kotlin in Action and Atomic Kotlin
-
Kotlin Koans Introduction Section


Meetup II
Conventions & Collections

Properties, Builders & Generics

Drone Food Delivery

Our Drone

-
Bluetooth connected drone
-
Parrot Android SDK
-
Grabber, Pellet gun, Camera
Drone Delivery

Android Controller
-
Control drone with existing android app
-
Take off, Land
-
Control pitch, yaw, roll, etc.
-
-
Converted it to Kotlin & cleaned it up
Drone Commands
-
Send higher level commands to drone
- Move one unit in any direction
- Fly to coordinate (x, y)
- Experimented with Coroutines
-
Wanted to explore a web framework
-
For handling food delivery requests
-
Went with Ktor
-
Created by Jetbrains
-
Written in Kotlin
-
For building async web servers & clients
-
Heavily uses coroutines for high scability
-
Really easy to safely async everything
-
Easy to use idomatic api
-
Great testing tools
-

Create a React-Kotlin app
-
Learned how to create a web app using the Kotlin wrappers for React.
-
Take advantage of Kotlin features to write expressive code that will compile to a React application
-
Really nice Kotlin DSL for building html
Using coroutines in your Android App
- Google codelab I did at KotlinConf
- Really great tutorial delivered by Sean McQuillan
- Start with an existing app built with callbacks
- Learn how to convert it to use coroutines
Kotlin Christmas Katas
-
Advent of Code challenges
-
These are some fun festive challenges
-
A great way to pick up new tips and tricks from the Kotlin library, particularly functional programming techniques!
Kotlin in 2018
-
In Toast
- Went from zero usage...
- To most people using it as their preferred JVM language
-
The fastest growing language in 2018
- 2.6 times the number of github contributors
-
One of the most loved languages of 2018
-
5-10 years ahead of Java
-
Kotlin 1.3 released
- Coroutines are stable
- Kotlin/Native is beta
- Lots of other improvements
Kotlin in 2018
Plans for 2019
- Build an Alexa skill in Kotlin
- Kotlin Spring night
- Another round of the Kotlin Koans
- Explore some Kotlin SQL libraries
- More drone delivery
- Flutter workshop
- Do Join Us!

Kotliners to follow on Twitter
-
Andrey Breslav - Lead language designer@Jetbrains
-
Roman Elizarov - Coroutines lead @Jetbrains
-
Hadi Hariri - Developer advocate @Jetbrains
-
Svetlana Isakova - Developer advocate & author @Jetbrains
-
Kotlin is a better language for the JVM than Java
-
Really easy to get up and running
-
Simpler language than Java
-
Much safer than Java
-
No more NullPointerExceptions!
-
Streamlines the handling of null values
-
-
More more clean & concise than Java
-
100% Interoperable with Java
-
Kotlin & Java classes can live side by side
-
-
To Summarise
Thank you
A Seamless Journey into the awesome world of Kotlin
By Tom Hanley
A Seamless Journey into the awesome world of Kotlin
- 135