SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
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
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
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
 
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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
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
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
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.
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 

Kürzlich hochgeladen (20)

How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
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 ...
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
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
 
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
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
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
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
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...
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 

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

Hinweis der Redaktion

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