SlideShare a Scribd company logo
1 of 36
To Kotlin or not to Kotlin,
That is the question
自我介紹
汪 永興
LINE 京都開發室
Freddie Wang
1.5M 50+ 250+
Developers Team size Contributors
Kotlin is designed for modernized
Java
• Readability (functional)
• Reuse (extensible, DSL-friendly)
• Interoperability with JVM
• Safety tooling (except the doc generation tool...)
Standing on the shoulder of giants
But definitely not
The improvement(?) from Java:
• Nullability
• Lambda + inline
• Properties
• Extension
• String template
• Operator overloading
• Data class
• Inner function
• No checked exception
val nullable: String? = "This is the wrong parent"
val nonnuable: String = null //Compiler error
val nullable: String? = null //OK
Nullability
Lambda + Inline
public inline fun measureTimeMillis(block: () -> Unit): Long {
val start = System.currentTimeMillis()
block()
return System.currentTimeMillis() - start
}
Lambda + Inline
public inline fun measureTimeMillis(block: () -> Unit): Long {
val start = System.currentTimeMillis()
block()
return System.currentTimeMillis() - start
}
Lambda + Inline
measureTimeMillis {
val jobs = List(1000) {
thread {
Thread.sleep(1000)
}
}
jobs.forEach { it.join() }
}
Lambda + Inline
measureTimeMillis {
val start = System.currentTimeMillis()
val jobs = List(1000) {
thread {
Thread.sleep(1000)
}
}
jobs.forEach { it.join() }
return System.currentTimeMillis() - start
}
Properties
class Image(val width: Int, val height: Int) {
val pixels: IntArray
init {
pixels = IntArray(this.width * this.height)
}
}
Properties
val image = Image(200, 200)
print(image.height) //200
inline fun AppCompatActivity.replaceFragment(
tag: String? = null,
animation: Boolean = false,
factory: (() -> Fragment)
) =
supportFragmentManager.beginTransaction().apply {
if (animation) {
setCustomAnimations(R.anim.fade_in, R.anim.fade_out)
}
replace(R.id.container, factory(), tag)
addToBackStack(null)
}.commit()
Extension
inline fun AppCompatActivity.replaceFragment(
tag: String? = null,
animation: Boolean = false,
factory: (() -> Fragment)
) =
supportFragmentManager.beginTransaction().apply {
if (animation) {
setCustomAnimations(R.anim.fade_in, R.anim.fade_out)
}
replace(R.id.container, factory(), tag)
addToBackStack(null)
}.commit()
Extension
override fun onCreate(savedInstanceState: Bundle?) {
...
replaceFragment {
MyFragment.newInstance()
}
}
Extension
Log.d(
TAG, "lineTo, from display point($x, $y), to internal point ($internalX, $internalY)"
)
String Template
Log.d(
TAG, "lineTo, from display point(" + x + "," + y + "), to internal point ( " +
internalX + " + "," + internalY + ")"
)
Operator Overloading
operator fun PointF.plus(pointB: PointF): PointF =
PointF(this.x + pointB.x, this.y + pointB.y)
Operator Overloading
operator fun PointF.plus(pointB: PointF): PointF =
PointF(this.x + pointB.x, this.y + pointB.y)
Operator Overloading
val p1 = controlPoint.add(prevPoint)
Operator Overloading
val p1 = controlPoint.add(prevPoint)
val p1 = controlPoint + prevPoint
Data class
data class Customer(var name: String, var email: String)
Neither need to create getter/setter manually, nor use the Lombok
Inner Function
fun dfs(graph: Graph) {
fun dfs(current: Vertex, visited: Set<Vertex>) {
if (!visited.add(current)) return
for (v in current.neighbors)
dfs(v, visited)
}
dfs(graph.vertices[0], HashSet())
}
Inner Function
fun dfs(graph: Graph) {
fun dfs(current: Vertex, visited: Set<Vertex>) {
if (!visited.add(current)) return
for (v in current.neighbors)
dfs(v, visited)
}
dfs(graph.vertices[0], HashSet())
}
No checked Exception
try {
FileReader file = new FileReader(file);
BufferedReader fileInput = new BufferedReader(file);
// ...
fileInput.readLine();
// ...
fileInput.close();
} catch (IOException e) {
// handle error
}
No checked Exception
try {
Data data = readData(filename);
} catch (IOException e) {
// handle error
}
No checked Exception
Data readData(String filename) throws IOException {
FileReader file = new FileReader(filename);
BufferedReader fileInput = new BufferedReader(file);
// ...
fileInput.readLine();
// ...
fileInput.close();
}
No checked Exception
Data readData(String filename) throws IOException {
FileReader file = new FileReader("test.txt");
BufferedReader fileInput = new BufferedReader(file);
// ...
fileInput.readLine();
// ...
fileInput.close();
}
No checked Exception
List<Result> results = fileNames.stream()
.map(filename -> readData(filename))
.collect(Collectors.toList());
No checked Exception
List<Result> results = fileNames.stream()
.map(filename -> readData(filename))
.collect(Collectors.toList());
No checked Exception
val results = filenames.map { filename -> readData(filename) }
Which projects are using Kotlin in LINE
• LINE android: 77% Java, 23% Kotlin
• Line Creator Studio (LINE拼貼): 100% Kotlin
• Clova SDK
• and others...
Summary
• If you don’t have any programming experience, learn Java first.
• If you are experienced Java developer, you should try Kotlin now.
• No doubt Kotlin will become more and more popular.
Q&A

More Related Content

What's hot

Scala for Java Devs
Scala for Java DevsScala for Java Devs
Scala for Java Devsloverdos
 
Flying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightFlying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightWiem Zine Elabidine
 
Using Onyx in anger
Using Onyx in angerUsing Onyx in anger
Using Onyx in angerSimon Belak
 
Save the princess
Save the princessSave the princess
Save the princessSimon Belak
 
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...
Fullstack Conference -  Proxies before proxies: The hidden gems of Javascript...Fullstack Conference -  Proxies before proxies: The hidden gems of Javascript...
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...Tim Chaplin
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScriptMark Shelton
 
3 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 20153 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 2015Manuel Bernhardt
 
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...Flink Forward
 
Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Seiya Mizuno
 
Journey's End – Collection and Reduction in the Stream API
Journey's End – Collection and Reduction in the Stream APIJourney's End – Collection and Reduction in the Stream API
Journey's End – Collection and Reduction in the Stream APIMaurice Naftalin
 
Joblib for cloud computing
Joblib for cloud computingJoblib for cloud computing
Joblib for cloud computingAlexandre Abadie
 
CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)Ortus Solutions, Corp
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014hezamu
 

What's hot (19)

Om nom nom nom
Om nom nom nomOm nom nom nom
Om nom nom nom
 
Scala for Java Devs
Scala for Java DevsScala for Java Devs
Scala for Java Devs
 
Pure Future
Pure FuturePure Future
Pure Future
 
Flying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnightFlying Futures at the same sky can make the sun rise at midnight
Flying Futures at the same sky can make the sun rise at midnight
 
Python to scala
Python to scalaPython to scala
Python to scala
 
Berlin meetup
Berlin meetupBerlin meetup
Berlin meetup
 
Spec + onyx
Spec + onyxSpec + onyx
Spec + onyx
 
Using Onyx in anger
Using Onyx in angerUsing Onyx in anger
Using Onyx in anger
 
Save the princess
Save the princessSave the princess
Save the princess
 
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...
Fullstack Conference -  Proxies before proxies: The hidden gems of Javascript...Fullstack Conference -  Proxies before proxies: The hidden gems of Javascript...
Fullstack Conference - Proxies before proxies: The hidden gems of Javascript...
 
Functional Programming with JavaScript
Functional Programming with JavaScriptFunctional Programming with JavaScript
Functional Programming with JavaScript
 
3 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 20153 things you must know to think reactive - Geecon Kraków 2015
3 things you must know to think reactive - Geecon Kraków 2015
 
Unary operator overloading
Unary operator overloadingUnary operator overloading
Unary operator overloading
 
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
Flink Forward San Francisco 2019: Build a Table-centric Apache Flink Ecosyste...
 
Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams Connect S3 with Kafka using Akka Streams
Connect S3 with Kafka using Akka Streams
 
Journey's End – Collection and Reduction in the Stream API
Journey's End – Collection and Reduction in the Stream APIJourney's End – Collection and Reduction in the Stream API
Journey's End – Collection and Reduction in the Stream API
 
Joblib for cloud computing
Joblib for cloud computingJoblib for cloud computing
Joblib for cloud computing
 
CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)CBStreams - Java Streams for ColdFusion (CFML)
CBStreams - Java Streams for ColdFusion (CFML)
 
Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014Functional UIs with Java 8 and Vaadin JavaOne2014
Functional UIs with Java 8 and Vaadin JavaOne2014
 

Similar to To kotlin or not to kotlin. That's the question

Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScriptChengHui Weng
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS ResponsibilitiesBrendan Eich
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queueAlex Eftimie
 
From Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksFrom Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksSeniorDevOnly
 
sbt core concepts (ScalaMatsuri 2019)
sbt core concepts (ScalaMatsuri 2019)sbt core concepts (ScalaMatsuri 2019)
sbt core concepts (ScalaMatsuri 2019)Eugene Yokota
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator OverloadingNilesh Dalvi
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?intelliyole
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016STX Next
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basicsopenbala
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojureAbbas Raza
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitVaclav Pech
 
CAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptxCAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptxSurajgroupsvideo
 

Similar to To kotlin or not to kotlin. That's the question (20)

Things about Functional JavaScript
Things about Functional JavaScriptThings about Functional JavaScript
Things about Functional JavaScript
 
JS Responsibilities
JS ResponsibilitiesJS Responsibilities
JS Responsibilities
 
Django Celery - A distributed task queue
Django Celery - A distributed task queueDjango Celery - A distributed task queue
Django Celery - A distributed task queue
 
From Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risksFrom Java to Scala - advantages and possible risks
From Java to Scala - advantages and possible risks
 
Introduction to Kotlin
Introduction to KotlinIntroduction to Kotlin
Introduction to Kotlin
 
sbt core concepts (ScalaMatsuri 2019)
sbt core concepts (ScalaMatsuri 2019)sbt core concepts (ScalaMatsuri 2019)
sbt core concepts (ScalaMatsuri 2019)
 
Operator Overloading
Operator OverloadingOperator Overloading
Operator Overloading
 
Kotlin: Why Do You Care?
Kotlin: Why Do You Care?Kotlin: Why Do You Care?
Kotlin: Why Do You Care?
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
 
SCALA - Functional domain
SCALA -  Functional domainSCALA -  Functional domain
SCALA - Functional domain
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basics
 
Introduction to clojure
Introduction to clojureIntroduction to clojure
Introduction to clojure
 
Pick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruitPick up the low-hanging concurrency fruit
Pick up the low-hanging concurrency fruit
 
CAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptxCAP444-Unit-3-Polymorphism.pptx
CAP444-Unit-3-Polymorphism.pptx
 
Scala ntnu
Scala ntnuScala ntnu
Scala ntnu
 

Recently uploaded

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfCionsystems
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendArshad QA
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 

Recently uploaded (20)

A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
Active Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdfActive Directory Penetration Testing, cionsystems.com.pdf
Active Directory Penetration Testing, cionsystems.com.pdf
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
Test Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and BackendTest Automation Strategy for Frontend and Backend
Test Automation Strategy for Frontend and Backend
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 

To kotlin or not to kotlin. That's the question

  • 1. To Kotlin or not to Kotlin, That is the question
  • 3. 1.5M 50+ 250+ Developers Team size Contributors
  • 4. Kotlin is designed for modernized Java
  • 5. • Readability (functional) • Reuse (extensible, DSL-friendly) • Interoperability with JVM • Safety tooling (except the doc generation tool...)
  • 6. Standing on the shoulder of giants
  • 8. The improvement(?) from Java: • Nullability • Lambda + inline • Properties • Extension • String template • Operator overloading • Data class • Inner function • No checked exception
  • 9. val nullable: String? = "This is the wrong parent" val nonnuable: String = null //Compiler error val nullable: String? = null //OK Nullability
  • 10. Lambda + Inline public inline fun measureTimeMillis(block: () -> Unit): Long { val start = System.currentTimeMillis() block() return System.currentTimeMillis() - start }
  • 11. Lambda + Inline public inline fun measureTimeMillis(block: () -> Unit): Long { val start = System.currentTimeMillis() block() return System.currentTimeMillis() - start }
  • 12. Lambda + Inline measureTimeMillis { val jobs = List(1000) { thread { Thread.sleep(1000) } } jobs.forEach { it.join() } }
  • 13. Lambda + Inline measureTimeMillis { val start = System.currentTimeMillis() val jobs = List(1000) { thread { Thread.sleep(1000) } } jobs.forEach { it.join() } return System.currentTimeMillis() - start }
  • 14. Properties class Image(val width: Int, val height: Int) { val pixels: IntArray init { pixels = IntArray(this.width * this.height) } }
  • 15. Properties val image = Image(200, 200) print(image.height) //200
  • 16. inline fun AppCompatActivity.replaceFragment( tag: String? = null, animation: Boolean = false, factory: (() -> Fragment) ) = supportFragmentManager.beginTransaction().apply { if (animation) { setCustomAnimations(R.anim.fade_in, R.anim.fade_out) } replace(R.id.container, factory(), tag) addToBackStack(null) }.commit() Extension
  • 17. inline fun AppCompatActivity.replaceFragment( tag: String? = null, animation: Boolean = false, factory: (() -> Fragment) ) = supportFragmentManager.beginTransaction().apply { if (animation) { setCustomAnimations(R.anim.fade_in, R.anim.fade_out) } replace(R.id.container, factory(), tag) addToBackStack(null) }.commit() Extension
  • 18. override fun onCreate(savedInstanceState: Bundle?) { ... replaceFragment { MyFragment.newInstance() } } Extension
  • 19. Log.d( TAG, "lineTo, from display point($x, $y), to internal point ($internalX, $internalY)" ) String Template Log.d( TAG, "lineTo, from display point(" + x + "," + y + "), to internal point ( " + internalX + " + "," + internalY + ")" )
  • 20. Operator Overloading operator fun PointF.plus(pointB: PointF): PointF = PointF(this.x + pointB.x, this.y + pointB.y)
  • 21. Operator Overloading operator fun PointF.plus(pointB: PointF): PointF = PointF(this.x + pointB.x, this.y + pointB.y)
  • 22. Operator Overloading val p1 = controlPoint.add(prevPoint)
  • 23. Operator Overloading val p1 = controlPoint.add(prevPoint) val p1 = controlPoint + prevPoint
  • 24. Data class data class Customer(var name: String, var email: String) Neither need to create getter/setter manually, nor use the Lombok
  • 25. Inner Function fun dfs(graph: Graph) { fun dfs(current: Vertex, visited: Set<Vertex>) { if (!visited.add(current)) return for (v in current.neighbors) dfs(v, visited) } dfs(graph.vertices[0], HashSet()) }
  • 26. Inner Function fun dfs(graph: Graph) { fun dfs(current: Vertex, visited: Set<Vertex>) { if (!visited.add(current)) return for (v in current.neighbors) dfs(v, visited) } dfs(graph.vertices[0], HashSet()) }
  • 27. No checked Exception try { FileReader file = new FileReader(file); BufferedReader fileInput = new BufferedReader(file); // ... fileInput.readLine(); // ... fileInput.close(); } catch (IOException e) { // handle error }
  • 28. No checked Exception try { Data data = readData(filename); } catch (IOException e) { // handle error }
  • 29. No checked Exception Data readData(String filename) throws IOException { FileReader file = new FileReader(filename); BufferedReader fileInput = new BufferedReader(file); // ... fileInput.readLine(); // ... fileInput.close(); }
  • 30. No checked Exception Data readData(String filename) throws IOException { FileReader file = new FileReader("test.txt"); BufferedReader fileInput = new BufferedReader(file); // ... fileInput.readLine(); // ... fileInput.close(); }
  • 31. No checked Exception List<Result> results = fileNames.stream() .map(filename -> readData(filename)) .collect(Collectors.toList());
  • 32. No checked Exception List<Result> results = fileNames.stream() .map(filename -> readData(filename)) .collect(Collectors.toList());
  • 33. No checked Exception val results = filenames.map { filename -> readData(filename) }
  • 34. Which projects are using Kotlin in LINE • LINE android: 77% Java, 23% Kotlin • Line Creator Studio (LINE拼貼): 100% Kotlin • Clova SDK • and others...
  • 35. Summary • If you don’t have any programming experience, learn Java first. • If you are experienced Java developer, you should try Kotlin now. • No doubt Kotlin will become more and more popular.
  • 36. Q&A

Editor's Notes

  1. Tools: IDE, plugin
  2. other languages support
  3. or Flowable
  4. or Flowable
  5. or Flowable
  6. or Flowable