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

Kotlin - The New Pragmatic Language

Kotlin - The New Pragmatic Language

Kotlin is concise, safe and pragmatic new programming language and is focused on interoperability with java code.

Avatar for Aadil Mehraj

Aadil Mehraj

October 24, 2018

Other Decks in Programming

Transcript

  1. What is Kotlin? • Consise, safe and modern programming language

    • Named after island in St. Petersburg • Statically-typed Programming language o Based on the JVM o Compact and Modern (“better Java”) o Open source • Created by JetBrains • Inspired by Java Programming Language, Swift, Scala, C#, Groovy amongst others • Targets platforms JVM / Android, Browser and Native • Similar to Java, but free of its legacy problems and limitations
  2. 2010 2011 2012 2016 Q2-Q4 2017 Q1 2017 Q2 2016

    Q1 Start Development History of Kotlin JetBrains unveiled Project Kotlin Open Sourced Released 1.01 – 1.07 Official Android support announced Released 1.0 Released 1.1
  3. History of Kotlin § In May 2017 Google I/O, Android

    team announced first-class support for Kotlin § In Oct 2018, Google teams up with JetBrains to form Kotlin Foundation o Protect, promote and advance the development of the Kotlin programming language. o Foundation secures Kotlin's development and distribution as Free Software Google I/O Keynote, 2017
  4. 1. Concise to reduce the amount of boilerplate code 2.

    Expressive to make code more readable and understandable. 3. Safe to avoid entire classes of errors such as NullPointerException. 4. Versatile for building server-side applications, Android apps, frontend code running in the browser and native binaries. 5. Interoperable to leverage existing frameworks and libraries of the JVM with 100 percent Java interoperability. Tenets of Kotlin
  5. Features of Kotlin • Null safety • Higher-order functions •

    Extension functions • Function types & lambdas • Default & named arguments • Properties • Type inference • Operator overloading • No checked exceptions • Smart casts • Data classes • Immutable collections • Enhanced switch-case • String templates • Ranges • Inline functions • Infix notation • Tail recursion • Coroutines(async/await) • Great Standard Library
  6. Extension Functions § A Function that can be called as

    a member of a class but is defined outside it § Adding behavior to a class without directly extending it
  7. Data Classes Data class overrides all standards Java methods: §

    equals for comparing instances § hashCodefor using them in hash-based containers § toString for generating string represetationof class
  8. String templates Embed variables and expressionsin strings by wrapping them

    in a pair of curly braces, prefixed by a $ symbol
  9. Default and Named Arguments Giving default value to the parameter

    of the function, making it optional Named Arguments allows changing the sequence of the parameter, by writing the argument name followed by assigning the value