SlideShare a Scribd company logo
Kotlin for Java Developers
what every java developer should know about kotlin
Today I would like to share with you
● Why I care about Kotlin?
● 20 features I love
● 10 features you need to be aware of
● Ecosystem
Next JVM language?
● Statically typed programming language for multi platform applications
○ concise
○ safe
○ interoperable with Java
○ built together with tooling support
○ open source under Apache 2.0 license
● Version 1.0 released in 2015, current version 1.1.50 (September 2017)
● Google announced first-class support for Kotlin on Android
● Pivotal introduced Kotlin support in Spring Framework 5.0
● Easy to learn if you know Java
Kotlin basics
Features I love
Extension functions and properties
Data classes
● equals() / hashCode() pair
● toString() “Account[email=test]”
● componentN() functions in their order
of declaration
● copy() function
String templates
Null safety
● Types defines nullability
○ Platform types
● Safe calls
● Elvis operator
● !!. operator
● Safe casts
when
Operator overloading
● +, -, *, /, %, ..
○ a + b -> a.plus(b)
○ a..b -> a.rangeTo(b)
● in, !in
○ a.contains(b)
● Indexed access []
○ a[i] -> a.get(i)
○ a[i] = b -> a.set(i, b)
● Invoke
○ a(i, j) -> a.invoke(i, j)
● a == b
○ a?.equals(b) ?: (b === null)
● a > b, a < b, a >= b, a <= b -> a.compareTo(b)
Operator overloading (1)
Default and named parameters
Smart casts
Destructuring objects
● underscore for unused
variables (1.1)
● destructuring in lambdas
(1.1)
Lambda and closures
Expressions and statements
● if and when are expressions, not statements
○ val length = if (a is String) a.length else -1
○ val action = when (test) {
in 0..5 -> OPEN
else -> CLOSE
}
● assignment is a statement, not an expression
○ if (a = b) does not compile
○ while ((line = bufferedReader.readLine()) != null) does not compile
Packages and source code structure
● packages
● import allows to import classes, functions, *
● type aliases
● multiple classes in one file
● arbitrary file names
● arbitrary directory structure
● visibility modifiers: private, protected, internal, public
Other languages have all these features
● Null safety
● No checked exceptions
● Extension functions
● Function types and lambdas
● Default and named parameters
● Properties
● Operator overloading
● Smart casts
● Data classes
● Immutable collections
● Enhanced switch-case
● String templates
● Ranges
● Infix notation
● Inline functions
● Coroutines (async/await)
● Great standard library
● Sealed classes
● Delegated and lazy properties
● Class delegation
● Singletons
● Nested functions
● Object decomposition
● Top-level functions
● Reified generics
● Raw strings
● 100% interoperable with Java 6
● And more...
Compile and run with Java code
● you can mix Java and Kotlin code in one project
● experiment with new language without breaking or rewriting the whole
application
● small memory footprint of the Kotlin standard library
Understand decisions
What you need to know
● final by default and bytecode generation
● platform types and nullability
● no primitives, no implicit widening conversions for numbers
● standard library
Final by default and bytecode generation
● all classes, methods are final by default
○ tedious opening via ‘open’ keyword
○ interference with AOP (CGLIB), workarounds as compiler plugins ‘kotlin-spring’, ‘all-open’
● ‘override’ is a required keyword, not an annotation
● designing for inheritance
● kotlinc generates Java 6 or Java 8 bytecode
● on JVM lambdas does not use ‘invokedynamic’
● Kotlin Bytecode Generation and Runtime Performance
Platform types and nullability (!)
● any reference in Java may be null
● types of Java declarations are called platform types
● can be assigned to nullable or non-null type
● compiler, tools refers to them using as T! which means T ot T?
● nullability annotations (JSR-305, Android, Lombok, JetBrains, Eclipse)
Standard library
● kotlin-runtime and kotlin-stdlib -> kotlin-stdlib
○ < 1MB jar (JVM)
● Kotlin classes and extension functions to Java classes
○ kotlin
○ kotlin.collections
○ kotlin.comparisons
○ kotlin.concurrent
○ kotlin.io
○ kotlin.streams
○ kotlin.text
● kotlin.js
Platforms and tooling
Platforms and tooling
● JVM
a. Java 6 and 8
● Android
● JavaScript (ES5.1)
a. compatible with module systems like AMD, CommonJS
● native (LLVM)
a. LLVM is used to compile Kotlin into native code
b. technology preview for iOS, linux, MAC, (windows in the work)
● IntelliJ IDEA (Java to Kotlin converter), Eclipse
● Gradle, Maven, Ant
Where to start?
● Try online https://try.kotlinlang.org/
● Kotlin is Awesome! https://kotlin.link/
What will be your next JVM
language?
https://en.wikipedia.org/wiki/List_of_JVM_languages

More Related Content

What's hot (20)

PDF
Object Oriented Programming : Part 2
Madhavan Malolan
 
PDF
Ruxmon.2013-08.-.CodeBro!
Christophe Alladoum
 
PDF
Clang Analyzer Tool Review
Doug Schuster
 
ODP
Phpactor and VIM
dantleech
 
PDF
Introduction to Kotlin JVM language
Andrius Klimavicius
 
PDF
Getting Started with PHP Extensions
MichaelBrunoLochemem
 
PDF
Kotlin & Arrow the functional way
Thoughtworks
 
PDF
A Shallow Survey of Alternative Languages on the JVM
Charles Anderson
 
PPTX
Modern Programming Languages - An overview
Ayman Mahfouz
 
PPTX
Android with kotlin course
Abdul Rahman Masri Attal
 
PDF
Kotlin & arrow: the functional way
nluaces
 
PPTX
Kotlin - A Programming Language
Mobio Solutions
 
PPTX
Coding in kotlin
Debmalya Jash
 
PDF
Java 8 Lambda
François Sarradin
 
PDF
Clojure presentation
Karthik Raghunahtan
 
KEY
Test-driven language development
lennartkats
 
PPTX
TypeScript intro
Ats Uiboupin
 
PDF
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
PPTX
.NET compiler platform codename Roslyn
Piotr Benetkiewicz
 
PDF
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 
Object Oriented Programming : Part 2
Madhavan Malolan
 
Ruxmon.2013-08.-.CodeBro!
Christophe Alladoum
 
Clang Analyzer Tool Review
Doug Schuster
 
Phpactor and VIM
dantleech
 
Introduction to Kotlin JVM language
Andrius Klimavicius
 
Getting Started with PHP Extensions
MichaelBrunoLochemem
 
Kotlin & Arrow the functional way
Thoughtworks
 
A Shallow Survey of Alternative Languages on the JVM
Charles Anderson
 
Modern Programming Languages - An overview
Ayman Mahfouz
 
Android with kotlin course
Abdul Rahman Masri Attal
 
Kotlin & arrow: the functional way
nluaces
 
Kotlin - A Programming Language
Mobio Solutions
 
Coding in kotlin
Debmalya Jash
 
Java 8 Lambda
François Sarradin
 
Clojure presentation
Karthik Raghunahtan
 
Test-driven language development
lennartkats
 
TypeScript intro
Ats Uiboupin
 
The Spoofax Language Workbench (SPLASH 2010)
lennartkats
 
.NET compiler platform codename Roslyn
Piotr Benetkiewicz
 
Lock-free algorithms for Kotlin Coroutines
Roman Elizarov
 

Similar to JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński) (20)

PPTX
Kotlin
Sudhanshu Vohra
 
PPTX
Kotlin
Ravi Pawar
 
PDF
Kotlin for Android Developers - 1
Mohamed Nabil, MSc.
 
PPSX
Kotlin Language powerpoint show file
Saurabh Tripathi
 
PDF
A Brief Overview of Kotlin
Sevil Güler
 
PDF
Kotlin from-scratch
Franco Lombardo
 
PDF
JavaOne 2016 - Kotlin: The Language of The Future For JVM?
Leonardo Zanivan
 
PDF
A Review Paper on Kotlin Programming Language
ijtsrd
 
PDF
Introduction to kotlin for Java Developer
troubledkumi
 
PDF
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
PDF
What’s new in Kotlin?
Squareboat
 
PPTX
Introduction to Kotlin
T.M. Ishrak Hussain
 
PDF
Kotlin: a better Java
Nils Breunese
 
PPTX
Kotlin Overview
Ekta Raj
 
PDF
Kotlin: A pragmatic language by JetBrains
Jigar Gosar
 
PDF
Why You Should Go with Kotlin for Android App Development.pdf
RipenApps
 
PPTX
Kotlin Native - C / Swift Interop - ACCU Autmn 2019
Eamonn Boyle
 
PDF
A quick and fast intro to Kotlin
XPeppers
 
PDF
Kotlin vs Java: Choosing The Right Language
FredReynolds2
 
PPTX
The-Future-of-Kotlin-What-Developers-Need-to-Know.pptx
JHK Infotech
 
Kotlin
Ravi Pawar
 
Kotlin for Android Developers - 1
Mohamed Nabil, MSc.
 
Kotlin Language powerpoint show file
Saurabh Tripathi
 
A Brief Overview of Kotlin
Sevil Güler
 
Kotlin from-scratch
Franco Lombardo
 
JavaOne 2016 - Kotlin: The Language of The Future For JVM?
Leonardo Zanivan
 
A Review Paper on Kotlin Programming Language
ijtsrd
 
Introduction to kotlin for Java Developer
troubledkumi
 
JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
What’s new in Kotlin?
Squareboat
 
Introduction to Kotlin
T.M. Ishrak Hussain
 
Kotlin: a better Java
Nils Breunese
 
Kotlin Overview
Ekta Raj
 
Kotlin: A pragmatic language by JetBrains
Jigar Gosar
 
Why You Should Go with Kotlin for Android App Development.pdf
RipenApps
 
Kotlin Native - C / Swift Interop - ACCU Autmn 2019
Eamonn Boyle
 
A quick and fast intro to Kotlin
XPeppers
 
Kotlin vs Java: Choosing The Right Language
FredReynolds2
 
The-Future-of-Kotlin-What-Developers-Need-to-Know.pptx
JHK Infotech
 
Ad

Recently uploaded (20)

PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PPTX
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
PPTX
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
PPTX
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
PDF
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
DOCX
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
PDF
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
“NPU IP Hardware Shaped Through Software and Use-case Analysis,” a Presentati...
Edge AI and Vision Alliance
 
Go Concurrency Real-World Patterns, Pitfalls, and Playground Battles.pdf
Emily Achieng
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
Building Search Using OpenSearch: Limitations and Workarounds
Sease
 
AUTOMATION AND ROBOTICS IN PHARMA INDUSTRY.pptx
sameeraaabegumm
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
The Project Compass - GDG on Campus MSIT
dscmsitkol
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
[Newgen] NewgenONE Marvin Brochure 1.pdf
darshakparmar
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
POV_ Why Enterprises Need to Find Value in ZERO.pdf
darshakparmar
 
IoT-Powered Industrial Transformation – Smart Manufacturing to Connected Heal...
Rejig Digital
 
Python coding for beginners !! Start now!#
Rajni Bhardwaj Grover
 
CIFDAQ Market Insights for July 7th 2025
CIFDAQ
 
Ad

JDD 2017: Kotlin for Java developers (Tomasz Kleszczyński)

  • 1. Kotlin for Java Developers what every java developer should know about kotlin
  • 2. Today I would like to share with you ● Why I care about Kotlin? ● 20 features I love ● 10 features you need to be aware of ● Ecosystem
  • 3. Next JVM language? ● Statically typed programming language for multi platform applications ○ concise ○ safe ○ interoperable with Java ○ built together with tooling support ○ open source under Apache 2.0 license ● Version 1.0 released in 2015, current version 1.1.50 (September 2017) ● Google announced first-class support for Kotlin on Android ● Pivotal introduced Kotlin support in Spring Framework 5.0 ● Easy to learn if you know Java
  • 7. Data classes ● equals() / hashCode() pair ● toString() “Account[email=test]” ● componentN() functions in their order of declaration ● copy() function
  • 9. Null safety ● Types defines nullability ○ Platform types ● Safe calls ● Elvis operator ● !!. operator ● Safe casts
  • 10. when
  • 11. Operator overloading ● +, -, *, /, %, .. ○ a + b -> a.plus(b) ○ a..b -> a.rangeTo(b) ● in, !in ○ a.contains(b) ● Indexed access [] ○ a[i] -> a.get(i) ○ a[i] = b -> a.set(i, b) ● Invoke ○ a(i, j) -> a.invoke(i, j) ● a == b ○ a?.equals(b) ?: (b === null) ● a > b, a < b, a >= b, a <= b -> a.compareTo(b)
  • 13. Default and named parameters
  • 15. Destructuring objects ● underscore for unused variables (1.1) ● destructuring in lambdas (1.1)
  • 17. Expressions and statements ● if and when are expressions, not statements ○ val length = if (a is String) a.length else -1 ○ val action = when (test) { in 0..5 -> OPEN else -> CLOSE } ● assignment is a statement, not an expression ○ if (a = b) does not compile ○ while ((line = bufferedReader.readLine()) != null) does not compile
  • 18. Packages and source code structure ● packages ● import allows to import classes, functions, * ● type aliases ● multiple classes in one file ● arbitrary file names ● arbitrary directory structure ● visibility modifiers: private, protected, internal, public
  • 19. Other languages have all these features ● Null safety ● No checked exceptions ● Extension functions ● Function types and lambdas ● Default and named parameters ● Properties ● Operator overloading ● Smart casts ● Data classes ● Immutable collections ● Enhanced switch-case ● String templates ● Ranges ● Infix notation ● Inline functions ● Coroutines (async/await) ● Great standard library ● Sealed classes ● Delegated and lazy properties ● Class delegation ● Singletons ● Nested functions ● Object decomposition ● Top-level functions ● Reified generics ● Raw strings ● 100% interoperable with Java 6 ● And more...
  • 20. Compile and run with Java code ● you can mix Java and Kotlin code in one project ● experiment with new language without breaking or rewriting the whole application ● small memory footprint of the Kotlin standard library
  • 22. What you need to know ● final by default and bytecode generation ● platform types and nullability ● no primitives, no implicit widening conversions for numbers ● standard library
  • 23. Final by default and bytecode generation ● all classes, methods are final by default ○ tedious opening via ‘open’ keyword ○ interference with AOP (CGLIB), workarounds as compiler plugins ‘kotlin-spring’, ‘all-open’ ● ‘override’ is a required keyword, not an annotation ● designing for inheritance ● kotlinc generates Java 6 or Java 8 bytecode ● on JVM lambdas does not use ‘invokedynamic’ ● Kotlin Bytecode Generation and Runtime Performance
  • 24. Platform types and nullability (!) ● any reference in Java may be null ● types of Java declarations are called platform types ● can be assigned to nullable or non-null type ● compiler, tools refers to them using as T! which means T ot T? ● nullability annotations (JSR-305, Android, Lombok, JetBrains, Eclipse)
  • 25. Standard library ● kotlin-runtime and kotlin-stdlib -> kotlin-stdlib ○ < 1MB jar (JVM) ● Kotlin classes and extension functions to Java classes ○ kotlin ○ kotlin.collections ○ kotlin.comparisons ○ kotlin.concurrent ○ kotlin.io ○ kotlin.streams ○ kotlin.text ● kotlin.js
  • 27. Platforms and tooling ● JVM a. Java 6 and 8 ● Android ● JavaScript (ES5.1) a. compatible with module systems like AMD, CommonJS ● native (LLVM) a. LLVM is used to compile Kotlin into native code b. technology preview for iOS, linux, MAC, (windows in the work) ● IntelliJ IDEA (Java to Kotlin converter), Eclipse ● Gradle, Maven, Ant
  • 28. Where to start? ● Try online https://try.kotlinlang.org/ ● Kotlin is Awesome! https://kotlin.link/
  • 29. What will be your next JVM language? https://en.wikipedia.org/wiki/List_of_JVM_languages