JavaOne 2016 - Kotlin: The Language of The Future For JVM?
1. Kotlin: The Language of The
Future For JVM?
Leonardo Zanivan @ JavaOne Latin America 2016 [SES12196]
2. Who am I?
➔ Leonardo Zanivan
◆ Software Architect
◆ OSS Contributor
◆ GUJavaSC Member
◆ JCP Member
3. First things first
➔ Why Kotlin?
◆ Concise
◆ Safe
◆ Versatile
◆ Interoperabile
◆ Tooling
4. First things first
➔ History
◆ Conceived in 2010
◆ Language and compiler are open source (Apache 2)
◆ To be a modern industry standard language
◆ With static typing and a smooth migration path
5. First things first
➔ Why should I care?
◆ Enterprise class support
◆ Production ready
◆ Java #1 language
◆ Productivity
6. First things first
➔ Who is using?
◆ GMC
◆ Expedia
◆ Prezi.com
◆ Telegram
◆ 99 Taxis
◆ JetBrains (IDEA, YouTrack, TeamCity)
7. Easy to learn
➔ Extensive documentation
◆ Online reference http://kotlinlang.org/docs
◆ Online editor & training http://try.kotlinlang.org
◆ Language documentation (PDF with 153 pages)
◆ Books (Kotlin in Action and Kotlin for Android)
◆ GitHub and StackOverflow activity
8. Easy to learn
➔ Fast startup
◆ Intuitive, easy to read & write (opposed to Scala)
◆ No force Functional or OOP styling
10. Easy to use
➔ Tooling support
◆ IDEA Community & Ultimate
◆ Android Studio
◆ Eclipse
◆ Maven / Ant / Gradle
◆ NetBeans plugin (experimental)
◆ Sonar plugin (experimental)
12. Easy to migrate
➔ Mix Java and Kotlin source files in the same project
➔ Java to Kotlin source conversion tool
➔ Compatible with Java 6 bytecode (100% compatible)
➔ Integrate with existing Java frameworks
➔ No runtime overhead
➔ No cost to adopt
14. Feature: Null safety out-of-the-box
val givenName: String? = null
val len = givenName?.length //assign null
val len = givenName!!.length //assert null
15. Feature: Lean syntax (no get/set)
data class Book(var title: String, var author: Author)
val book = Book(“Kotlin at JavaOne”,”Leonardo”)
println(book.title)
16. Feature: Smart casts and type inference
if (node is Leaf) {
return node.symbol;
}
val myString = "Some text"
23. Other features
➔ Exceptions are all unchecked
➔ Easy to use builder pattern (copy)
➔ Operator overloading (==, +, -, !, etc.)
➔ Better generics syntax (no wildcards)
➔ Automatic delegation pattern syntax
➔ String interpolation (idioms)
➔ KAPT (Kotlin annotation processor)
➔ What about multi-threading, etc? It’s all in Java!
24. Comparison w/ other emergent (flame war)
➔ Node.js
◆ No support to Java ecosystem
◆ Java is way faster than Node.js
➔ Go
◆ Statically linked (no VM)
◆ No support to Java ecosystem
◆ JVM is faster than Go
25. What’s the catch?
➔ Data class can’t inherit or be inherited
➔ Classes are final by default (you need to open)
➔ Compilation is incremental only in IDEA and Gradle
➔ Lack some FP functions (can use funKTionale lib)
➔ Null safety checks could be trick in the beginning
➔ Some reserved words conflicts (Mockito*)
26. Roadmap
➔ async/await/yield
➔ Data class hierarchy support
➔ Type aliases
➔ Bound method references
➔ Take advantage of Java 7/8 bytecode enhancements
➔ Back to work on JavaScript support