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

Kotlin For Swift Developers - CocoaHeads NL, Amsterdam, March 2018

Kotlin For Swift Developers - CocoaHeads NL, Amsterdam, March 2018

Video from this version of the presentation:
https://www.youtube.com/watch?v=Tzgh4OTWv4c

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).

Now with actual links to some books I've been working on!

Ellen Shapiro

March 21, 2018
Tweet

More Decks by Ellen Shapiro

Other Decks in Technology

Transcript

  1. KOTLIN FOR SWIFT DEVELOPERS COCOAHEADS NL | AMSTERDAM | 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 ▸ Kotlin

    Native Is Cool But Not Ready For Production
  20. OBLIGATORY SUMMARY SLIDE ▸ Make Friends With Android ▸ Kotlin

    Native Is Cool But Not Ready For Production try! Kotlin
  21. 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
  22. MORE LINKS! ▸ Creating an iOS Framework With Kotlin http://viteinfinite.com/2018/02/creating-

    an-ios-framework-with-kotlin ▸ RayWenderlich.com Android Avalanche™ https://www.raywenderlich.com/187520/ introducing-the-android-avalanche