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.

Introduction to Kotlin JVM language

722 views

Published on

Kotlin is a statically typed programming language for the JVM, Android and the browser designed for the industry. This presentation is an overview of Kotlin features and advantages over Java including code samples.

Published in: Technology
  • Be the first to comment

Introduction to Kotlin JVM language

  1. 1. An Introduction to Kotlin JVM language Andrius Klimavičius
  2. 2. Intro • JVM language • Android and browser support. • Developed by JetBrains • Open Source • First appeared in 2011 • Still in Beta (v1.0.0-beta-3595)
  3. 3. Kotlin google: kotlin logo
  4. 4. Modern Language for Industry • 100% interoperable with Java • Concise - no boilerplate code • Safe - convert runtime errors into compile time • Tools support (command-line, plugins) • Targets Java 6
  5. 5. Comparison • Runtime error -> Compile time errors
  6. 6. Kotlin addresses Java problems • Null references are controlled by the type system. • No raw types • Arrays in Kotlin are invariant • Kotlin has proper function types, as opposed to Java’s SAM-conversions • Kotlin does not have checked exceptions • Use-site variance without wildcards (<? extends T>)
  7. 7. Kotlin vs Java • No checked exceptions • No primitive types that are not classes • No static members • No non-private fields • No wildcard-types
  8. 8. Kotlin vs Java (2) • Function literals + Inline functions • Extension functions • Null-safety • Smart casts • String templates • Properties • First-class delegation • Type inference • Singletons • Range expressions • Operator overloading • Companion objects
  9. 9. Features • String templates • Named arguments & defaults (verbose code) • Lambda expressions • Null-Safety (nullable, non-nullable refs) • Functional programming methods (filter,map,…) • Extensions (like Objective-C, C#) • Auto generated POJOs (data class)
  10. 10. Features (2) • Destructuring Declarations • Generics (Java) • Ranges • Operator Overloading • Optional semi-colons • Android support • ….
  11. 11. Hello World!
  12. 12. Variables
  13. 13. String templates
  14. 14. String templates
  15. 15. Functions
  16. 16. Named params & defaults
  17. 17. Lambda expressions
  18. 18. Null-safety
  19. 19. Basic FP methods like filtering
  20. 20. Extensions
  21. 21. Data classes
  22. 22. Smart Casts
  23. 23. Call Java from Kotlin println("Code in Kotlin")
  24. 24. Call Kotlin from Java
  25. 25. Reference • https://kotlinlang.org • https://prezi.com/5krzwy15ixea/kotlin-on- android-mobiconf-2015/

×