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

Kotlin for Swift Developers - try! Swift Tokyo,...

Kotlin for Swift Developers - try! Swift Tokyo, March 2018

Video:
https://www.youtube.com/watch?v=JK2s6n80Sl8

Kotlin is a new language born on the JVM that's gained a ton of popularity with Android developers. Learn about its similarities and differences with swift, and a bit about where it's going in the future (though it's not quiiiiite there yet).

Ellen Shapiro

March 02, 2018
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. KOTLIN FOR SWIFT DEVELOPERS (SWIFT εЀυϘί΄͵Η΄KOTLIN) TRY! SWIFT | TOKYO,

    JAPAN | MARCH 2018 @DESIGNATEDNERD | BAKKENBAECK.COM | JUSTHUM.COM
  2. !"

  3. !"

  4. SWIFT func useFunction<T, U>(on item: T, function: (T) -> U)

    -> U { return function(item) } func insertExclamationPoint(in string: String) -> String { return string .components(separatedBy: " ") .joined(separator: "! ") } let result = useFunction(on: "try Swift", function: insertExclamationPoint(in:)) // result: "try! Swift"
  5. KOTLIN fun <T, U>T.useFunction(action: (T) -> U): U { return

    action(this) } fun insertExclamationPoint(in: String) : String { return in.split(" ").joinToString("! ") } val result = "try Kotlin".useFunction { insertExclamationPoint(it) } // result: "try! Kotlin"
  6. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(0, +) // reduced: 6
  7. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(0, +) // ! // reduced: 6
  8. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(0) { $0 + $1 } // reduced: 6
  9. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(20) { $0 + $1 } // reduced: 26
  10. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(20) { $0 + $1 } // reduced: 26 KOTLIN val numbers = arrayOf(1, 2, 3) val reduced = numbers.reduce { total, current -> total + current } // reduced: 6
  11. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(20) { $0 + $1 } // reduced: 26 ⬆ KOTLIN val numbers = arrayOf(1, 2, 3) val reduced = numbers.reduce { total, current -> total + current } // reduced: 6
  12. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(20) { $0 + $1 } // reduced: 26 KOTLIN val numbers = arrayOf(1, 2, 3) val folded = numbers.fold(20) ⬅ { total, current -> total + current } // folded: 26
  13. SWIFT let doubled = [ 1, 2, 3 ].map {

    $0 * 2 } KOTLIN arrayOf(1, 2, 3).map { it * 2 }
  14. SWIFT let doubled = [ 1, 2, 3 ].map {

    $0 * 2 } KOTLIN arrayOf(1, 2, 3).map { it * 2 }
  15. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(20) { $0 + $1 } // reduced: 26
  16. SWIFT let numbers = [ 1, 2, 3 ] let

    reduced = numbers.reduce(20) { $0 + $1 } // reduced: 26 KOTLIN val numbers = arrayOf(1, 2, 3) val folded = numbers.fold(20) { total, current -> total + current } // folded: 26 ⬆
  17. !"#

  18. SUPPORTED PLATFORMS ▸ x86-64 (macOS, Linux, Windows) ▸ arm64 (iOS,

    Android) ▸ arm32 (Android) ▸ arm32 hardfp (Raspberry Pi) ▸ WebAssembly (Web)
  19. OBLIGATORY SUMMARY SLIDE (嬝㵗ጱ΀ᥝ夹) ▸ Make Friends With Android ▸

    (Android ;լᜉͥ΀Σ͜) ▸ Kotlin Native Is Cool But Not Ready For Production ▸ (Kotlin Native΅͡͹̵͚͚ͩ͢ϤϺύ μτϴЀ΁΅ΔͶֵ͞΀͚)
  20. LINKS! ▸ Kotlin Home & Documentation https://kotlinlang.org ▸ KotlinConf iOS

    App in Kotlin/Native: https://github.com/JetBrains/ kotlinconf-app/tree/master/ios ▸ The Edu Tools Plugin for IntelliJ or Android Studio https://kotlinlang.org/docs/ tutorials/edu-tools-learner.html