Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Kotlin - a JUG.RU talk, 2016

600 views

Published on

TimePad event: https://jugru.timepad.ru/event/296642/
Habrahbr announcement: https://habrahabr.ru/company/jugru/blog/277871/
Videos:
- https://www.youtube.com/watch?v=HWyd1gYMkl0
- https://www.youtube.com/watch?v=LWFx4QWrTyo

Published in: Technology
  • Be the first to comment

Kotlin - a JUG.RU talk, 2016

  1. 1. Andrey Breslav
  2. 2. http://kotlinlang.org
  3. 3. JetBrains
  4. 4. • Pragmatic language for industry – Started in 2010 – Open Source – 1.0 Released in Feb, 2016 • For JVM, Android, and JavaScript – Interoperability: 100% • Try online: https://try.kotl.in
  5. 5. bytecode Kotlin
  6. 6. Technicalities • Few compiler optimizations – inlning as a language feature • Compiler intergated into the IDE • Incrementality
  7. 7. Requirements • Statically typed • “Toolable” (is this a word at all?) • Interoperable (yes, C++ has been there!) • Learnable (“democratic”)
  8. 8. Comparing to others
  9. 9. Over 500K LOC of Kotlin: IntelliJ IDEA Rider (C# IDE) YouTrack JetBrains Account (and more)
  10. 10. In Open-Source Projects, Kotlin itself excluded
  11. 11. In Open-Source Projects, Kotlin itself excluded
  12. 12. IDE Compiler (Incremental) Build System
  13. 13. Java *.kt *.java compiler Javacompiler
  14. 14. “Billion dollar mistake” — Sir C. A. R. Hoare
  15. 15. Java String s = null; s.length(); Errors At Runtime Kotlin val s: String s.length() val s: String? = null s.length() Errors At Compile Time = null Nullable type
  16. 16. Check and use val s: String? = … if (s != null) { s.length() } Check and exit if (s == null) return s.length() Rock’n’Roll s?.length() s!!.length() (s ?: “…”).length()
  17. 17. Kotlin is good with nulls
  18. 18. What about Java?
  19. 19. Java (as seen from Kotlin) public class JavaClass { public String foo(List<String> l) {…} } String String? List<String> List<String?> List<String>? List<String?>? Safest!
  20. 20. Java Interop: All Nullable javaValue.toString().length() + 1 javaValue?.toString()?.length()!! + 1 val l: List<String> = javaValue?.getList()!! ArrayList<String?>
  21. 21. Your safest option doesn’t work!
  22. 22. Annotations public class JavaClass { @NotNull public String foo(@NotNull List<String> l) {…} } String String? List<String> List<String?> List<String>? List<String?>?
  23. 23. Annotations are cumbersome AND don’t really help!
  24. 24. Pick Two • Null-safety • Convenience • Java Interop Platform Types! Thanks to Dr. Ross Tate of
  25. 25. Java: Platform Types public class JavaClass { public String foo(Bar<String> l) {…} } String! Bar<String!>! Platform Type
  26. 26. Dereferencing Platform Values s: String s: String? s: String! s.length() s.length() s.length() s?.length() s?.length() s?.length() s!!.length() s!!.length() s!!.length() NPE
  27. 27. Assignability String String? String! Platform Type NPE
  28. 28. Some Notes • Platform Types are Not Denotable! – String! is notation, not syntax • Pure Kotlin is Null-Safe • Kotlin+Java is as safe as Java • Annotations Still Applicable – @NotNull String in Java becomes String in Kotlin • Dynamic Type for JavaScript Interop – JS is even unsafer than Java
  29. 29. Nullable types: Summary Cost • More Complexity • Less Null-Safety Benefit • Smooth Interop
  30. 30. http://kotlinlang.org
  31. 31. Images Used • http://blogs.msdn.com/cfs- filesystemfile.ashx/__key/communityserver-blogs-components- weblogfiles/00-00-01-32-02- metablogapi/8054.image_5F00_thumb_5F00_35C6E986.png • http://www.complete-coherence.com/wp- content/uploads/2015/06/Is-business-rational-or-emotional.jpg • http://www.mightyheaton.com/wp-content/uploads/2012/05/33- 1024x908.jpg • https://openclipart.org/image/2400px/svg_to_png/97543/text-file- icon.png • http://fileinfo.com/img/icons/files/128/class-737.png • http://1.bp.blogspot.com/- UK5uEhDELUA/T9duhHrDeII/AAAAAAAAB20/nKpYXYhqub4/s1600/ application-x-jar%5B1%5D.png

×