Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Hold on! Here is Kotlin. One language to rule t...

Avatar for Sevil Sevil
December 05, 2018

Hold on! Here is Kotlin. One language to rule them all.

Kotlin is a statically typed programming language for modern multi-platform applications and it’s 100% interoperable with Java. In this presentation, I will talk about the pros and cons of Kotlin from a general aspect, focusing on five Ws: Who, What, Why, When, How. The presentation will end with code samples to show the strength of Kotlin.

Avatar for Sevil

Sevil

December 05, 2018
Tweet

More Decks by Sevil

Other Decks in Programming

Transcript

  1. HISTORY ▸ Not new at all 2011 -> 2012, Saint

    Petersburg ▸ Created by Jetbrains To increase their productivity Drive company business by keeping trust Drive sales of Intellij IDEA ▸ February 15, 2016 ▸ Google IO - 2017
  2. INTRODUCTION ▸ Industrial-strength Object Oriented language - it is pragmatic

    ▸ Open Source ▸ Interoperable with Java ▸ Concise and Expressive ▸ Easy to learn ▸ Terrific Support and great tools ▸ Safe ▸ Better Efficiency as a Programmer
  3. LANGUAGE FEATURES ▸ Static typing Compile time 1. Performance is

    better 2. More reliable 3. Easier to maintain Type Inference (in contrast to Java) ▸ Object Oriented and Functional Design around object and supports OO concepts Not purely functional but : A. Lambda Expressions B. First class functions, immutability and no side effects ▸ Lambdas (High Order Functions) ▸ Compatible ▸ Incremental Compilation ▸ Null Safety Java Code is defensive (NPE) Safe Call Operator (?) Safe Cast Operator (as?) Elvis Operator (?:)
  4. LANGUAGE FEATURES ▸ Extension Functions Extend any class with new

    feature even we don’t have access to the source code ▸ Operator Overloading Can provide implementation for a predefined set of operators like +, =, == ▸ Generics Different types, same behaviour Reflection, smart casts, companion objects, range expressions etc. ▸ Data Classes Simplify classes Separate pure data from business logic
  5. COMPARING TO JAVA 1. Checked Exceptions 2. Primitives types 3.

    Static members 4. Non-private fields 5. Wildcard types 1. Lambda expressions (inline functions) 2. Extension functions 3. Null Safety 4. Smart casts 5. String templates 6. Properties 7. Singletons 8. Operator Overloading 9. Companion Objects 10. Data Classes 11. Coroutines 12.…… JAVA: 5 - KOTLIN : 0 JAVA: 0 - KOTLIN : 12…
  6. COMPARE WITH ▸ Same conciseness and expressive code BUT Kotlin

    wins with static typing and null safety ‣ Difficult to compare but … ‣ Very similar where Swift is LLVM based and C interop
  7. THE PRESENT OF THE KOTLIN ▸ Google, Amazon, Foursquare, Capital

    One, Coursera, Basecamp,Netflix, Uber, Trello, Pinterest, Corda etc. are using Kotlin ▸ Google I/O
  8. THE PRESENT OF THE KOTLIN ▸ It is not only

    Java/Android language but compile projects can also compile into JS.
  9. THE PRESENT OF THE KOTLIN ▸ JavaScript target, allowing you

    to compile Kotlin code to JS and to run it in your browser - Kotlin 1.1 ▸ Concept of common module - platform specific functionality for multiplatform project - Kotlin 1.2 A multiplatform project allows you to build multiple tiers of your application – backend, frontend and Android app – from the same codebase. ▸ Reuse the code between JVM and JS ▸ write the business logic of your application once, and reuse it across all tiers of your application – the backend, the browser frontend and the Android mobile app.
  10. KOTLIN EXAMPLES ▸ Example 1: ▸ if (object != null

    && object.getOtherObject() != null) { String someString = object.getOtherObject().getSomeString(); if (someString != null) { return someString; } return “”; } —- >JAVA ▸ return someObject?.getSomeOtherObject()?.getSomeString() ?: “" —-> KOTLIN ▸ Example 2: -> Intellij IDEA
  11. THE FUTURE OF THE KOTLIN ▸ Support for machine code

    Kotlin/Native - Beta ▸ Mutliplatform programming (reusing code with Android) in Kotlin 1.2 and 1.3 - exp ▸ Android — iOS ▸ Client — Server ▸ Embedded systems/IoT (e.g., Arduino and beyond) ▸ Data analysis and Scientific Computing ▸ Server-side and Microservices (low-footprint executables, utilizing the power of coroutines) ▸ Game Development
  12. DISADVANTAGES ▸ larger file package size than one built purely

    in Java. ▸ Build time for Kotlin is a little slower using Gradle