SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Is there Kotlin after Java 8
Ivan Turčinović & Igor Buzatović
What is Kotlin?General
2
Statically typed, JVM-targeted language
Design principles: Industrial use, tooling, safety
Compiles to JVM byte code and JavaScript
Runtime size 800K
Current status, plans, release dateGeneral
No release date, no spec yet
Roadmap
M1 → M2 → … → Beta → Jetbrains project → V1.0
Latest milestone → M7
3
Some frameworks/libraries already appeared
Kara Web Framework – Statically typed HTML/CSS
Spek – Specification/test framework
Kannotator – Infer annotations from bytecode
KotlinPrimavera - Kotlin libraries to Spring projects
Java strikes back with Java 8
Advantages over Java 7 are overwhelming
Java 8 introduced
Lambdas
General
4
Lambdas
Null safety (“Optional” class)
Default methods
Streams API
New Date & Time API
But even with Java 8 Kotlin still...
Is more elegant, concise and safe
General
5
Has more cool stuff
Basic syntax and rulesMore elegant?
Functions - definition in
package or in class
Immutable/mutable
variables
No „new” keyword
Type inference
6
Type inference
No checked exceptions
No primitive types
No static members
More elegant? Basic syntax and rules cont’d
7
Primary constructors
No fields, just properties
Bean style classes easy to declare
By default, all classes are final
More elegant?
Null safety
• Null reference – Billion dollar mistake
• Kotlin is designed in a way that aims to
eliminate NPE from our code
8
GenericsMore elegant?
Not co-variant by default, reason?
Wildcards, use-site variance
Co-variance price, producers
Contra-variance, consumers
Bloch: "PECS: Producer extend,
Consumer super“
Java
9
Declaration-site variance
out / in generics modifiers
Supports use-site variance also
No wildcard syntax, out / in used
Kotlin
Java survey: 39% of wildcards usage can be replaced by declaration-site variance
Default arguments, named argumentsMore cool stuff
Default argument values can
be defined
Arguments with default
values are optional
No more need for function
overloading (almost)
10
overloading (almost)
Kotlin classes can have only
one constructor
Arguments can be called by
name
When passing arguments by
name ordering doesn’t
matter
RangesMore cool stuff
Simpler “is it in range” check
Can be used for any type
that implements
Comparable
“both ends“ included
“..” operator is translated to
“rangeTo” function
11
“rangeTo” function
“rangeTo” function is
implemented as extension
function on Comparable
Numerical ranges can be
iterated over
In both directions and in
arbitrary steps
Pattern matchingMore cool stuff
Java’s instaceof not very practical
No !instanceof
Meet Kotlin’s "is“
12
"is" negation "!is“
Automatic type cast when “is”
evaluates true inside if / when
blocks
Data classesMore cool stuff
Classes very easy to declare
Data annotation changes
13
Output
javacro.User@41a7d9e7
1101519335
1926426205
false
Data annotation changes
behavior of hashCode,
equals, toString functions
Default implementation uses
all properties
Off course we can override
Data classesMore cool stuff
Classes very easy to declare
Data annotation changes
14
Output
User(firstName=John,lastName=Doe)
71819599
71819599
true
Data annotation changes
behavior of hashCode,
equals, toString functions
Default implementation uses
all properties
Off course we can override
Operator overloadingMore cool stuff
Operators are translated to
corresponding functions
Operator set is fixed
Operator overloading is achieved by
overriding corresponding functions of
specific class
15
specific class
By adding extension functions we can
enable certain operator for classes that
don’t support it originally
On our own classes we can enable
certain operator by implementing
corresponding functions
Extension functionsMore cool stuff
What to do if we want to add features
to existing classes
Java: extending or utility classes
Kotlin: add functions to existing
classes without changing their code
Example: implement BigDecimal +
16
Example: implement BigDecimal +
operator
How does it work “behind the scene”?
Extension functionsMore cool stuff
What to do if we want to add features
to existing classes
Java: extending or utility classes
Kotlin: add functions to existing
classes without changing their code
Example: implement BigDecimal +
17
Example: implement BigDecimal +
operator
How does it work “behind the scene”?
Kotlin collectionsMore cool stuff
18
Read-only traits on top, co-variant
Extended by mutable traits
Implemented by JDK classes (compile time modifications)
Read-only traits do not guarantee immutability
Top level package functions for instantiating collections:
Read-only: setOf, listOf, mapOf
Mutable: hashSetOff, arrayListOf, hashMapOf
Type-safe Groovy-style buildersMore cool stuff
19
For generating tree-like structures (UI layouts, 3D scene graphs)
Tree-like syntax – better insight in what is being generated
Functions create, initialize and return builder specific objects
Better then xml: no scheme required, type safe, interoperable with other code
Type-safe Groovy-style buildersMore cool stuff
Objects initialized using
function literal argument
Extension function literal
allows referencing to object
enclosing element
20
enclosing element
Kara web framework using it
for HTML layouts, CSS
Android apps, XML layouts
Thank You!
21
Thank You!

Mais conteúdo relacionado

Mais procurados

An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profiling
schlebu
 
JAVA 8 Parallel Stream
JAVA 8 Parallel StreamJAVA 8 Parallel Stream
JAVA 8 Parallel Stream
Tengwen Wang
 

Mais procurados (19)

Gatling
Gatling Gatling
Gatling
 
Java 8 parallel stream
Java 8 parallel streamJava 8 parallel stream
Java 8 parallel stream
 
Scala
ScalaScala
Scala
 
An Introduction To Java Profiling
An Introduction To Java ProfilingAn Introduction To Java Profiling
An Introduction To Java Profiling
 
Java7 - Top 10 Features
Java7 - Top 10 FeaturesJava7 - Top 10 Features
Java7 - Top 10 Features
 
Hybrid Applications
Hybrid ApplicationsHybrid Applications
Hybrid Applications
 
JAVA 8 Parallel Stream
JAVA 8 Parallel StreamJAVA 8 Parallel Stream
JAVA 8 Parallel Stream
 
Smart Migration to JDK 8
Smart Migration to JDK 8Smart Migration to JDK 8
Smart Migration to JDK 8
 
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
TDC São Paulo 2019 - Trilha DevTest - Karatê DSL - Automatizando testes de AP...
 
Lagergren jvmls-2013-final
Lagergren jvmls-2013-finalLagergren jvmls-2013-final
Lagergren jvmls-2013-final
 
Graal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT CompilerGraal in GraalVM - A New JIT Compiler
Graal in GraalVM - A New JIT Compiler
 
Java 8 concurrency abstractions
Java 8 concurrency abstractionsJava 8 concurrency abstractions
Java 8 concurrency abstractions
 
Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)Nashorn: JavaScript that doesn’t suck (ILJUG)
Nashorn: JavaScript that doesn’t suck (ILJUG)
 
Survive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and TricksSurvive JavaScript - Strategies and Tricks
Survive JavaScript - Strategies and Tricks
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)
Akka (BeJUG)
 
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
КОСТЯНТИН КЛЮЄВ «Postman: API Automation Testing Swiss Army Knife» Kyiv QADay...
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2
Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2
Why and how Pricing Assistant migrated from Celery to RQ - Paris.py #2
 
rx-java-presentation
rx-java-presentationrx-java-presentation
rx-java-presentation
 

Destaque

The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
intelliyole
 

Destaque (20)

The Kotlin Programming Language
The Kotlin Programming LanguageThe Kotlin Programming Language
The Kotlin Programming Language
 
Kotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime PerformanceKotlin Bytecode Generation and Runtime Performance
Kotlin Bytecode Generation and Runtime Performance
 
JavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan Raguž
JavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan RagužJavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan Raguž
JavaCro'14 - Java in M2M technologies – Mango M2M software – Ivan Raguž
 
JavaCro'14 - Vaadin scalability myth – Gordan Ivanović
JavaCro'14 - Vaadin scalability myth – Gordan IvanovićJavaCro'14 - Vaadin scalability myth – Gordan Ivanović
JavaCro'14 - Vaadin scalability myth – Gordan Ivanović
 
JavaCro'14 - Automatic database migrations – Marko Elezović
JavaCro'14 - Automatic database migrations – Marko ElezovićJavaCro'14 - Automatic database migrations – Marko Elezović
JavaCro'14 - Automatic database migrations – Marko Elezović
 
JavaCro'14 - GWT rebooted – Gordan Krešić
JavaCro'14 - GWT rebooted – Gordan KrešićJavaCro'14 - GWT rebooted – Gordan Krešić
JavaCro'14 - GWT rebooted – Gordan Krešić
 
JavaCro'14 - How to handle large amounts of data in real time using a cloud e...
JavaCro'14 - How to handle large amounts of data in real time using a cloud e...JavaCro'14 - How to handle large amounts of data in real time using a cloud e...
JavaCro'14 - How to handle large amounts of data in real time using a cloud e...
 
JavaCro'14 - Gatling – weapon in ranks of performance testing – Andrija Kranjec
JavaCro'14 - Gatling – weapon in ranks of performance testing – Andrija KranjecJavaCro'14 - Gatling – weapon in ranks of performance testing – Andrija Kranjec
JavaCro'14 - Gatling – weapon in ranks of performance testing – Andrija Kranjec
 
JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander...
JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander...JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander...
JavaCro'14 - Automatized testing with Selenium 2 – Juraj Ćutić and Aleksander...
 
JavaCro'14 - Cloud Platforms in Internet of Things – Krešimir Mišura and Bran...
JavaCro'14 - Cloud Platforms in Internet of Things – Krešimir Mišura and Bran...JavaCro'14 - Cloud Platforms in Internet of Things – Krešimir Mišura and Bran...
JavaCro'14 - Cloud Platforms in Internet of Things – Krešimir Mišura and Bran...
 
JavaCro'14 - Is there a single “correct” web architecture for business apps –...
JavaCro'14 - Is there a single “correct” web architecture for business apps –...JavaCro'14 - Is there a single “correct” web architecture for business apps –...
JavaCro'14 - Is there a single “correct” web architecture for business apps –...
 
JavaCro'14 - Can You Tell Me How to Get to Sesame Street I wanna be a Grails ...
JavaCro'14 - Can You Tell Me How to Get to Sesame Street I wanna be a Grails ...JavaCro'14 - Can You Tell Me How to Get to Sesame Street I wanna be a Grails ...
JavaCro'14 - Can You Tell Me How to Get to Sesame Street I wanna be a Grails ...
 
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
JavaCro'14 - Securing web applications with Spring Security 3 – Fernando Redo...
 
JavaCro'14 - Sustainability of business performance and best practices – Zlat...
JavaCro'14 - Sustainability of business performance and best practices – Zlat...JavaCro'14 - Sustainability of business performance and best practices – Zlat...
JavaCro'14 - Sustainability of business performance and best practices – Zlat...
 
JavaCro'14 - MEAN Stack – How & When – Nenad Pećanac
JavaCro'14 - MEAN Stack – How & When – Nenad PećanacJavaCro'14 - MEAN Stack – How & When – Nenad Pećanac
JavaCro'14 - MEAN Stack – How & When – Nenad Pećanac
 
JavaCro'14 - JCalc Calculations in Java with open source API – Davor Sauer
JavaCro'14 - JCalc Calculations in Java with open source API – Davor SauerJavaCro'14 - JCalc Calculations in Java with open source API – Davor Sauer
JavaCro'14 - JCalc Calculations in Java with open source API – Davor Sauer
 
JavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan Kljajin
JavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan KljajinJavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan Kljajin
JavaCro'14 - WebSockets and OpenLayers joined with Spring – Bojan Kljajin
 
JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...
JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...
JavaCro'14 - Auditing of user activity through NoSQL database – Kristijan Duv...
 
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
JavaCro'14 - Developing Google Chromecast applications on Android – Branimir ...
 
JavaCro'14 - Profile any environment with Java Flight Recorder – Johan Janssen
JavaCro'14 - Profile any environment with Java Flight Recorder – Johan JanssenJavaCro'14 - Profile any environment with Java Flight Recorder – Johan Janssen
JavaCro'14 - Profile any environment with Java Flight Recorder – Johan Janssen
 

Semelhante a JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović

Java jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mJava jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3m
Steve Elliott
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
Ken Coenen
 

Semelhante a JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović (20)

Introduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTXIntroduction to Kotlin - Android KTX
Introduction to Kotlin - Android KTX
 
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and StreamsIntroduction of Java 8 with emphasis on Lambda Expressions and Streams
Introduction of Java 8 with emphasis on Lambda Expressions and Streams
 
Java basic
Java basicJava basic
Java basic
 
Kotlin presentation
Kotlin presentation Kotlin presentation
Kotlin presentation
 
Power Up Your Build - Omer van Kloeten @ Wix 2018-04
Power Up Your Build - Omer van Kloeten @ Wix 2018-04Power Up Your Build - Omer van Kloeten @ Wix 2018-04
Power Up Your Build - Omer van Kloeten @ Wix 2018-04
 
Getting Started With Kotlin
Getting Started With KotlinGetting Started With Kotlin
Getting Started With Kotlin
 
C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1C, C++ Interview Questions Part - 1
C, C++ Interview Questions Part - 1
 
Why Kotlin?
Why Kotlin?Why Kotlin?
Why Kotlin?
 
What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.What's new with Kotlin - Google IO18' extended Covenant University.
What's new with Kotlin - Google IO18' extended Covenant University.
 
What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)What is Java Technology (An introduction with comparision of .net coding)
What is Java Technology (An introduction with comparision of .net coding)
 
9054799 dzone-refcard267-kotlin
9054799 dzone-refcard267-kotlin9054799 dzone-refcard267-kotlin
9054799 dzone-refcard267-kotlin
 
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
 
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
 
Java jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3mJava jdk-update-nov10-sde-v3m
Java jdk-update-nov10-sde-v3m
 
Basics of kotlin ASJ
Basics of kotlin ASJBasics of kotlin ASJ
Basics of kotlin ASJ
 
Java 7 & 8
Java 7 & 8Java 7 & 8
Java 7 & 8
 
Scalax
ScalaxScalax
Scalax
 
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018Kotlin @ Coupang Backed - JetBrains Day seoul 2018
Kotlin @ Coupang Backed - JetBrains Day seoul 2018
 
Rapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and KtorRapid Web API development with Kotlin and Ktor
Rapid Web API development with Kotlin and Ktor
 
Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?Kotlin – Alternative oder Ergänzung zu Java?
Kotlin – Alternative oder Ergänzung zu Java?
 

Mais de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association

Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association
 

Mais de HUJAK - Hrvatska udruga Java korisnika / Croatian Java User Association (20)

Java cro'21 the best tools for java developers in 2021 - hujak
Java cro'21   the best tools for java developers in 2021 - hujakJava cro'21   the best tools for java developers in 2021 - hujak
Java cro'21 the best tools for java developers in 2021 - hujak
 
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK KeynoteJavaCro'21 - Java is Here To Stay - HUJAK Keynote
JavaCro'21 - Java is Here To Stay - HUJAK Keynote
 
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan LozićJavantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
Javantura v7 - Behaviour Driven Development with Cucumber - Ivan Lozić
 
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
Javantura v7 - The State of Java - Today and Tomowwow - HUJAK's Community Key...
 
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
Javantura v7 - Learning to Scale Yourself: The Journey from Coder to Leader -...
 
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
JavaCro'19 - The State of Java and Software Development in Croatia - Communit...
 
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander RadovanJavantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
Javantura v6 - Java in Croatia and HUJAK - Branko Mihaljević, Aleksander Radovan
 
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
Javantura v6 - On the Aspects of Polyglot Programming and Memory Management i...
 
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
Javantura v6 - Case Study: Marketplace App with Java and Hyperledger Fabric -...
 
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
Javantura v6 - How to help customers report bugs accurately - Miroslav Čerkez...
 
Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...Javantura v6 - When remote work really works - the secrets behind successful ...
Javantura v6 - When remote work really works - the secrets behind successful ...
 
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej VidakovićJavantura v6 - Kotlin-Java Interop - Matej Vidaković
Javantura v6 - Kotlin-Java Interop - Matej Vidaković
 
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
Javantura v6 - Spring HATEOAS hypermedia-driven web services, and clients tha...
 
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
Javantura v6 - End to End Continuous Delivery of Microservices for Kubernetes...
 
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
Javantura v6 - Istio Service Mesh - The magic between your microservices - Ma...
 
Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...Javantura v6 - How can you improve the quality of your application - Ioannis ...
Javantura v6 - How can you improve the quality of your application - Ioannis ...
 
Javantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela PetracJavantura v6 - Just say it v2 - Pavao Varela Petrac
Javantura v6 - Just say it v2 - Pavao Varela Petrac
 
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje RuhekJavantura v6 - Automation of web apps testing - Hrvoje Ruhek
Javantura v6 - Automation of web apps testing - Hrvoje Ruhek
 
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
Javantura v6 - Master the Concepts Behind the Java 10 Challenges and Eliminat...
 
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario KusekJavantura v6 - Building IoT Middleware with Microservices - Mario Kusek
Javantura v6 - Building IoT Middleware with Microservices - Mario Kusek
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 

JavaCro'14 - Is there Kotlin after Java 8 – Ivan Turčinović and Igor Buzatović

  • 1. Is there Kotlin after Java 8 Ivan Turčinović & Igor Buzatović
  • 2. What is Kotlin?General 2 Statically typed, JVM-targeted language Design principles: Industrial use, tooling, safety Compiles to JVM byte code and JavaScript Runtime size 800K
  • 3. Current status, plans, release dateGeneral No release date, no spec yet Roadmap M1 → M2 → … → Beta → Jetbrains project → V1.0 Latest milestone → M7 3 Some frameworks/libraries already appeared Kara Web Framework – Statically typed HTML/CSS Spek – Specification/test framework Kannotator – Infer annotations from bytecode KotlinPrimavera - Kotlin libraries to Spring projects
  • 4. Java strikes back with Java 8 Advantages over Java 7 are overwhelming Java 8 introduced Lambdas General 4 Lambdas Null safety (“Optional” class) Default methods Streams API New Date & Time API
  • 5. But even with Java 8 Kotlin still... Is more elegant, concise and safe General 5 Has more cool stuff
  • 6. Basic syntax and rulesMore elegant? Functions - definition in package or in class Immutable/mutable variables No „new” keyword Type inference 6 Type inference No checked exceptions No primitive types No static members
  • 7. More elegant? Basic syntax and rules cont’d 7 Primary constructors No fields, just properties Bean style classes easy to declare By default, all classes are final
  • 8. More elegant? Null safety • Null reference – Billion dollar mistake • Kotlin is designed in a way that aims to eliminate NPE from our code 8
  • 9. GenericsMore elegant? Not co-variant by default, reason? Wildcards, use-site variance Co-variance price, producers Contra-variance, consumers Bloch: "PECS: Producer extend, Consumer super“ Java 9 Declaration-site variance out / in generics modifiers Supports use-site variance also No wildcard syntax, out / in used Kotlin Java survey: 39% of wildcards usage can be replaced by declaration-site variance
  • 10. Default arguments, named argumentsMore cool stuff Default argument values can be defined Arguments with default values are optional No more need for function overloading (almost) 10 overloading (almost) Kotlin classes can have only one constructor Arguments can be called by name When passing arguments by name ordering doesn’t matter
  • 11. RangesMore cool stuff Simpler “is it in range” check Can be used for any type that implements Comparable “both ends“ included “..” operator is translated to “rangeTo” function 11 “rangeTo” function “rangeTo” function is implemented as extension function on Comparable Numerical ranges can be iterated over In both directions and in arbitrary steps
  • 12. Pattern matchingMore cool stuff Java’s instaceof not very practical No !instanceof Meet Kotlin’s "is“ 12 "is" negation "!is“ Automatic type cast when “is” evaluates true inside if / when blocks
  • 13. Data classesMore cool stuff Classes very easy to declare Data annotation changes 13 Output javacro.User@41a7d9e7 1101519335 1926426205 false Data annotation changes behavior of hashCode, equals, toString functions Default implementation uses all properties Off course we can override
  • 14. Data classesMore cool stuff Classes very easy to declare Data annotation changes 14 Output User(firstName=John,lastName=Doe) 71819599 71819599 true Data annotation changes behavior of hashCode, equals, toString functions Default implementation uses all properties Off course we can override
  • 15. Operator overloadingMore cool stuff Operators are translated to corresponding functions Operator set is fixed Operator overloading is achieved by overriding corresponding functions of specific class 15 specific class By adding extension functions we can enable certain operator for classes that don’t support it originally On our own classes we can enable certain operator by implementing corresponding functions
  • 16. Extension functionsMore cool stuff What to do if we want to add features to existing classes Java: extending or utility classes Kotlin: add functions to existing classes without changing their code Example: implement BigDecimal + 16 Example: implement BigDecimal + operator How does it work “behind the scene”?
  • 17. Extension functionsMore cool stuff What to do if we want to add features to existing classes Java: extending or utility classes Kotlin: add functions to existing classes without changing their code Example: implement BigDecimal + 17 Example: implement BigDecimal + operator How does it work “behind the scene”?
  • 18. Kotlin collectionsMore cool stuff 18 Read-only traits on top, co-variant Extended by mutable traits Implemented by JDK classes (compile time modifications) Read-only traits do not guarantee immutability Top level package functions for instantiating collections: Read-only: setOf, listOf, mapOf Mutable: hashSetOff, arrayListOf, hashMapOf
  • 19. Type-safe Groovy-style buildersMore cool stuff 19 For generating tree-like structures (UI layouts, 3D scene graphs) Tree-like syntax – better insight in what is being generated Functions create, initialize and return builder specific objects Better then xml: no scheme required, type safe, interoperable with other code
  • 20. Type-safe Groovy-style buildersMore cool stuff Objects initialized using function literal argument Extension function literal allows referencing to object enclosing element 20 enclosing element Kara web framework using it for HTML layouts, CSS Android apps, XML layouts