SlideShare une entreprise Scribd logo
1  sur  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

Contenu connexe

Tendances

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
 

Tendances (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
 

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

pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
Hiroshi Ono
 
Functional programming basics
Functional programming basicsFunctional programming basics
Functional programming basics
openbala
 

Similaire à 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
 

Dernier

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
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Dernier (20)

10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
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
 
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-...
 
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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
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
 
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
 
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...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
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 ...
 
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
 
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
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
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
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 

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

Notes de l'éditeur

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