## Slide 1

### Slide 1 text

KOTLIN FOR SWIFT DEVELOPERS (SWIFT εЀυϘί΄͵Η΄KOTLIN) TRY! SWIFT | TOKYO, JAPAN | MARCH 2018 @DESIGNATEDNERD | BAKKENBAECK.COM | JUSTHUM.COM

## Slide 2

### Slide 2 text

HEY, @d_date THANK YOU FOR THE TRANSLATION! (෭๜承΅扖ͭΔͱ

!"

No content

No content

No content

No content

No content

No content

No content

✨ " ☕ \$ ✨

No content

## Slide 13

### Slide 13 text

WHAT IS KOTLIN ? ( KOTLIN ᥺承͹ͼ֜ Ҙ)

No content

No content

No content

No content

## Slide 18

### Slide 18 text

WHY SHOULD I CARE? ( ΀Ͳᐺ΅䶲΁ͯΡ΄͡?)

No content

No content

## Slide 21

### Slide 21 text

A CONSTANT STRING

## Slide 22

### Slide 22 text

SWIFT let greeting = "Hello World"

## Slide 23

### Slide 23 text

SWIFT let greeting = "Hello World" KOTLIN val greeting = "Hello World"

## Slide 24

### Slide 24 text

AN OPTIONAL INTEGER VARIABLE

## Slide 25

### Slide 25 text

SWIFT var something: Int?

## Slide 26

### Slide 26 text

SWIFT var something: Int? KOTLIN var something: Int?

## Slide 27

### Slide 27 text

☠ NullPointerException ☠

!"

## Slide 29

### Slide 29 text

GENERICS AND FUNCTIONS AS PARAMETERS ( Ϟ϶ϮЄό;ͭͼֵ͞Ρ樛හ)

## Slide 30

### Slide 30 text

SWIFT func useFunction(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"

## Slide 31

### Slide 31 text

KOTLIN fun 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"

## Slide 32

### Slide 32 text

map filter reduce

## Slide 33

### Slide 33 text

map filter reduce*

## Slide 34

### Slide 34 text

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

## Slide 35

### Slide 35 text

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

## Slide 36

### Slide 36 text

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

## Slide 37

### Slide 37 text

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

## Slide 38

### Slide 38 text

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

## Slide 39

### Slide 39 text

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

## Slide 40

### Slide 40 text

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

## Slide 41

### Slide 41 text

SWIFT let doubled = [ 1, 2, 3 ].map { \$0 * 2 }

## Slide 42

### Slide 42 text

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

No content

No content

## Slide 45

### Slide 45 text

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

## Slide 46

### Slide 46 text

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

\$0 \$1 \$2...\$∞

## Slide 48

### Slide 48 text

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 ⬆

No content

!"#

No content

guard

## Slide 53

### Slide 53 text

NOW (匍ࣁ) (KOTLIN) optionalThing?.let { it.doSomething() }

## Slide 54

### Slide 54 text

NOW (匍ࣁ) (WORSE KOTLIN) if (optionalThing != nil) { optionalThing!!.doSomething() }

## Slide 55

### Slide 55 text

PROPOSED (൉ໜ) (KOTLIN) guard val thing = optionalThing else { return } thing.doSomething()

apply

## Slide 57

### Slide 57 text

NOW (匍ࣁ) (SWIFT) UserDefaults.standard.set(true, forKey: "DefaultOne") UserDefaults.standard.set(false, forKey: "DefaultTwo)

## Slide 58

### Slide 58 text

NOW (匍ࣁ) (BETTER SWIFT) let defaults = UserDefaults.standard defaults.set(true, forKey: "DefaultOne") defaults.set(false, forKey: "DefaultTwo)

## Slide 59

### Slide 59 text

PROPOSED (൉ໜ) (SWIFT) UserDefaults.standard.apply { "DefaultOne" = true, "DefaultTwo" = false, }

No content

No content

KOTLIN / NATIVE

LLVM

LLVM

LLVM

## Slide 66

### Slide 66 text

SUPPORTED PLATFORMS ▸ x86-64 (macOS, Linux, Windows) ▸ arm64 (iOS, Android) ▸ arm32 (Android) ▸ arm32 hardfp (Raspberry Pi) ▸ WebAssembly (Web)

No content

No content

DOCUMENTATION

## Slide 70

### Slide 70 text

DOCUMENTATION? ¯\_(ϑ)_/¯

## Slide 71

### Slide 71 text

KOTLIN: ☕ OR " = #

try? kotlin

## Slide 73

### Slide 73 text

https://try.kotlinlang.org

No content

No content

## Slide 76

### Slide 76 text

EDU TOOLS PLUGIN FOR INTELLIJ OR ANDROID STUDIO (INTELLIJ Δ͵΅ ANDROID STUDIO አ΄Ϥ϶ναЀ)

No content

No content

## Slide 79

### Slide 79 text

OBLIGATORY SUMMARY SLIDE (嬝㵗ጱ΀ᥝ夹) ▸

## Slide 80

### Slide 80 text

OBLIGATORY SUMMARY SLIDE (嬝㵗ጱ΀ᥝ夹) ▸ Make Friends With Android ▸ (Android ;լᜉͥ΀Σ͜)

## Slide 81

### Slide 81 text

OBLIGATORY SUMMARY SLIDE (嬝㵗ጱ΀ᥝ夹) ▸ Make Friends With Android ▸ (Android ;լᜉͥ΀Σ͜) ▸ Kotlin Native Is Cool But Not Ready For Production ▸ (Kotlin Native΅͡͹̵͚͚ͩ͢ϤϺύ μτϴЀ΁΅ΔͶֵ͞΀͚)

try! Kotlin

ONE MORE THING

✨ "#\$ ✨

## Slide 85

### Slide 85 text

͘Π͢;͚ͪͬ͜Δͭ͵! (THANK YOU VERY MUCH!)

## Slide 86

### Slide 86 text

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

## Slide 87

### Slide 87 text

MORE LINKS! ▸ Creating an iOS Framework With Kotlin http://viteinfinite.com/2018/02/creating-an-ios- framework-with-kotlin

## Slide 88

### Slide 88 text

ILLUSTRATION CREDITS ▸ Monica Komperda, Native Code Forever (Hire her! She's awesome!) http://mokomperda.com/design