1. A Friend In Need Is a Friend Indeed
Kotlin / Java Interop
Andrey Breslav
Wednesday, August 1, 12 1
2. Kotlin
Modern Language for Industry
• Smart compiler • Static typing
➡ Less boilerplate • Readability
• Flexible abstractions • Tool support
➡ Powerful libraries • Interoperability
2
Wednesday, August 1, 12 2
3. Stuff
• Apache 2 • IDE
• Target ➡ IntelliJ
➡ JVM (1.6) ➡ Web Demo
➡ JavaScript
*
• Build
➡ Ant
➡ Maven
3
* Planned
Wednesday, August 1, 12 3
16. Summary
• Use JDK collections in Kotlin
• Extend them with useful operations
• Make them variant for Kotlin
• At the expense of some unsoundness
around the edges
13
Wednesday, August 1, 12 13
19. Nullable Types Summary
• null is a legitimate value, not a sin
• No overhead (as opposed to Option)
• Proper subtyping:
➡ List<String> is a List<String?>
• At the expense of:
file.getParent()!!.getName()!!
16
Wednesday, August 1, 12 16
20. Annotations to The Rescue
String String?
JSR 305: Annotations for Software Defect Detection
17
Wednesday, August 1, 12 17
21. Generics?!
@NotNull
doesn't
help
18
Wednesday, August 1, 12 18
24. It Is Not So Bad
• IDE aids annotating with quick fixes
• Some annotations can be inferred
automatically
• Alternative: have a special kind of types
for Java things
21
Wednesday, August 1, 12 21
25. Statics
Packages
Class Objects
Wednesday, August 1, 12 22