Slide 1

Slide 1 text

THE BASIC KOTLIN GDG DevFest
 Incheon 2017 pluulove

Slide 2

Slide 2 text

GDG DevFest
 Incheon 2017 Android Developer GDG Korea Android Organizer Android / Kotlin @pluulove

Slide 3

Slide 3 text

GDG DevFest
 Incheon 2017 WHAT THE KOTLIN?

Slide 4

Slide 4 text

GDG DevFest
 Incheon 2017 Statically typed programming language for modern multiplatform applications 100% interoperable with Java™ and Android™

Slide 5

Slide 5 text

GDG DevFest
 Incheon 2017

Slide 6

Slide 6 text

GDG DevFest
 Incheon 2017

Slide 7

Slide 7 text

GDG DevFest
 Incheon 2017

Slide 8

Slide 8 text

GDG DevFest
 Incheon 2017 OVERVIEW

Slide 9

Slide 9 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array): Unit { println("Hello, world!") }

Slide 10

Slide 10 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array): Unit { println("Hello, world!") } Function Keyword

Slide 11

Slide 11 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array): Unit { println("Hello, world!") } Function Name

Slide 12

Slide 12 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array): Unit { println("Hello, world!") } Parameter Name

Slide 13

Slide 13 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array): Unit { println("Hello, world!") } Parameter Type

Slide 14

Slide 14 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array): Unit { println("Hello, world!") } Return Type

Slide 15

Slide 15 text

GDG DevFest
 Incheon 2017 fun main(args: Array): Unit { println("Hello, world!") } Basic Return Type Unit return type can be omitted

Slide 16

Slide 16 text

GDG DevFest
 Incheon 2017 Basic fun main(args: Array) { println("Hello, world!") }

Slide 17

Slide 17 text

GDG DevFest
 Incheon 2017 val text: String = null val text: String = null // Error, non-null Type Null Safe

Slide 18

Slide 18 text

GDG DevFest
 Incheon 2017 val text: String? = null Null Safe

Slide 19

Slide 19 text

GDG DevFest
 Incheon 2017 val text: String? = null Null Safe Nullable Keyword

Slide 20

Slide 20 text

GDG DevFest
 Incheon 2017 val text: String? = null Null Safe

Slide 21

Slide 21 text

GDG DevFest
 Incheon 2017 val text: String? = null text = 100.toString() Null Safe val text: String? = null text = 100.toString() // Error, Immutable Data

Slide 22

Slide 22 text

GDG DevFest
 Incheon 2017 val text: String? = null text = 100.toString() Null Safe Immutable

Slide 23

Slide 23 text

GDG DevFest
 Incheon 2017 var text: String? = null text = 100.toString() Null Safe Mutable

Slide 24

Slide 24 text

GDG DevFest
 Incheon 2017 if (data != null && data.value != null) { data.value.toString(); } Null Safe (2)

Slide 25

Slide 25 text

GDG DevFest
 Incheon 2017 data?.value?.toString() Null Safe (2)

Slide 26

Slide 26 text

GDG DevFest
 Incheon 2017 val l: Int = if (b != null) b.length else -1 Null Safe (3) ~ Elvis Operator val l = b?.length ?: -1 https://kotlinlang.org/docs/reference/null-safety.html#elvis-operator

Slide 27

Slide 27 text

GDG DevFest
 Incheon 2017 val l: Int = if (b != null) b.length else -1 Null Safe (3) ~ Elvis Operator val l = b?.length ?: -1 Elvis Operator https://kotlinlang.org/docs/reference/null-safety.html#elvis-operator

Slide 28

Slide 28 text

GDG DevFest
 Incheon 2017 fun foo(node: Node): String? { val parent = node.getParent() ?: return null val name = node.getName() ?: 
 throw IllegalArgumentException("name expected") // ... } Null Safe (3) ~ Elvis Operator https://kotlinlang.org/docs/reference/null-safety.html#elvis-operator

Slide 29

Slide 29 text

GDG DevFest
 Incheon 2017 Type Inference val s: String = "Value"

Slide 30

Slide 30 text

GDG DevFest
 Incheon 2017 Type Inference val s = "Value" // String val c = 'V' // Char val i = 10 // Int val l = 10L // Long val f = 10F // Float val d = 10.0 // Double val b = true // Boolean val sb = StringBuilder() // StringBuilder

Slide 31

Slide 31 text

GDG DevFest
 Incheon 2017 Control Flow if / when / try

Slide 32

Slide 32 text

GDG DevFest
 Incheon 2017 Control Flow Statement No Return Value Return Value Expression

Slide 33

Slide 33 text

GDG DevFest
 Incheon 2017 Control Flow (if / when / try) int a = 10; String value; if (a > 10) { value = "Over 10"; } else { value = "Under 10"; } val a = 10 val value: String if (a > 10) { value = "Over 10" } else { value = "Under 10" } Java Kotlin

Slide 34

Slide 34 text

GDG DevFest
 Incheon 2017 Control Flow (if / when / try) int a = 10; String value; if (a > 10) { value = "Over 10"; } else { value = "Under 10"; } val a = 10 val value = if (a > 10) { "Over 10" } else { "Under 10" } Java Kotlin

Slide 35

Slide 35 text

GDG DevFest
 Incheon 2017 val a = 10 val value = if (a > 10) "Over 10" else "Under 10" Control Flow (if / when / try) Kotlin

Slide 36

Slide 36 text

GDG DevFest
 Incheon 2017 Control Flow (if / when / try) String value; switch (a) { case 1: value = "one"; break; case 2: value = "two"; break; case 3: value = "three"; break; default: value = "another"; break; } val value: String when { a === 1 -> value = "one" a === 2 -> value = "two" a === 3 -> value = "three" else -> value = "another" } Java Kotlin

Slide 37

Slide 37 text

GDG DevFest
 Incheon 2017 Control Flow (if / when / try) String value; switch (a) { case 1: value = "one"; break; case 2: value = "two"; break; case 3: value = "three"; break; default: value = "another"; break; } val value = when(a) { 1 -> "one" 2 -> "two" 3 -> "three" else -> "another" } Java Kotlin

Slide 38

Slide 38 text

GDG DevFest
 Incheon 2017 when (x) { parseInt(s) -> print("s encodes x") in 1..10 -> print("x is in the range") in validNumbers -> print("x is valid") !in 10..20 -> print("x is outside the range") else -> print("none of the above") } Control Flow (if / when / try) Kotlin

Slide 39

Slide 39 text

GDG DevFest
 Incheon 2017 when (x) { parseInt(s) -> print("s encodes x") in 1..10 -> print("x is in the range") in validNumbers -> print("x is valid") !in 10..20 -> print("x is outside the range") else -> print("none of the above") } Control Flow (if / when / try) Kotlin Expression

Slide 40

Slide 40 text

GDG DevFest
 Incheon 2017 when (x) { parseInt(s) -> print("s encodes x") in 1..10 -> print("x is in the range") in validNumbers -> print("x is valid") !in 10..20 -> print("x is outside the range") else -> print("none of the above") } Control Flow (if / when / try) Kotlin Range

Slide 41

Slide 41 text

GDG DevFest
 Incheon 2017 when (x) { parseInt(s) -> print("s encodes x") in 1..10 -> print("x is in the range") in validNumbers -> print("x is valid") !in 10..20 -> print("x is outside the range") else -> print("none of the above") } Control Flow (if / when / try) Kotlin Not in Range

Slide 42

Slide 42 text

GDG DevFest
 Incheon 2017 when (x) { parseInt(s) -> print("s encodes x") in 1..10 -> print("x is in the range") in validNumbers -> print("x is valid") !in 10..20 -> print("x is outside the range") else -> print("none of the above") } Control Flow (if / when / try) Kotlin Optional, statement / expression

Slide 43

Slide 43 text

GDG DevFest
 Incheon 2017 Default Parameter public String foo(String name, int number, boolean toUpperCase) { return (toUpperCase ? name.toUpperCase() : name) + number; } public String foo(String name, int number) { return foo(name, number, false); } public String foo(String name, boolean toUpperCase) { return foo(name, 42, toUpperCase); } public String foo(String name) { return foo(name, 42); } Java

Slide 44

Slide 44 text

GDG DevFest
 Incheon 2017 Default Parameter public String foo(String name, int number, boolean toUpperCase) { return (toUpperCase ? name.toUpperCase() : name) + number; } public String foo(String name, int number) { return foo(name, number, false); } public String foo(String name, boolean toUpperCase) { return foo(name, 42, toUpperCase); } public String foo(String name) { return foo(name, 42); } Java Default Default

Slide 45

Slide 45 text

GDG DevFest
 Incheon 2017 Default Parameter fun foo(name: String, number: Int = 42, toUpperCase: Boolean = false) = (if (toUpperCase) name.toUpperCase() else name) + number Kotlin

Slide 46

Slide 46 text

GDG DevFest
 Incheon 2017 Default Parameter fun foo(name: String, number: Int = 42, toUpperCase: Boolean = false) = (if (toUpperCase) name.toUpperCase() else name) + number Kotlin

Slide 47

Slide 47 text

GDG DevFest
 Incheon 2017 Example class Item { private String type1; private int type2; private float type3; private float type4; } ▸ setter / getter ▸ hashCode ▸ equals ▸ toString

Slide 48

Slide 48 text

class Item { private String type1; private int type2; private float type3; private float type4; public Item(String type1, int type2, float type3, float type4) { this.type1 = type1; this.type2 = type2; this.type3 = type3; this.type4 = type4; } public String getType1() { return type1; } public void setType1(String type1) { this.type1 = type1; } GDG DevFest
 Incheon 2017 Example

Slide 49

Slide 49 text

GDG DevFest
 Incheon 2017 class Item { private String type1; private int type2; private float type3; private float type4; public Item(String type1, int type2, float type3, float type4) { this.type1 = type1; this.type2 = type2; this.type3 = type3; this.type4 = type4; } public String getType1() { return type1; } public void setType1(String type1) { this.type1 = type1; } public int getType2() { return type2; } public void setType2(int type2) { this.type2 = type2; } public float getType3() { return type3; } public void setType3(float type3) { this.type3 = type3; } public float getType4() { return type4; } public void setType4(float type4) { this.type4 = type4; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Item item = (Item) o; if (type2 != item.type2) return false; if (Float.compare(item.type3, type3) != 0) return false; if (Float.compare(item.type4, type4) != 0) return false; return type1 != null ? type1.equals(item.type1) : item.type1 == null; } @Override public int hashCode() { int result = type1 != null ? type1.hashCode() : 0; result = 31 * result + type2; result = 31 * result + (type3 != +0.0f ? Float.floatToIntBits(type3) : 0); result = 31 * result + (type4 != +0.0f ? Float.floatToIntBits(type4) : 0); return result; } @Override public String toString() { return "Item{" + "type1='" + type1 + '\'' + ", type2=" + type2 + ", type3=" + type3 + ", type4=" + type4 + '}'; } } ӡ~~~~~~~~~~׮ ߸ࣻ ୶о/࢏ઁद ߸҃ ੘স਷ 
 ݅݅ೞ૑ ঋ׮ Example

Slide 50

Slide 50 text

GDG DevFest
 Incheon 2017 Data Class data class Item( var type1: String?, var type2: Int, var type3: Float, var type4: Float)

Slide 51

Slide 51 text

GDG DevFest
 Incheon 2017 Data Class data class Item( var type1: String?, var type2: Int, var type3: Float, var type4: Float) Data Class Keyword

Slide 52

Slide 52 text

GDG DevFest
 Incheon 2017 Data Class data class Item(var type1: String?, var type2: Int, var type3: Float, var type4: Float) // Create Single variable val item = Item(1.toString(), 2, 3.toFloat(), 4.toFloat()) // Create Destructuring Declarations val (type1, type2, type3, type4) = 
 Item(1.toString(), 2, 3.toFloat(), 4.toFloat())

Slide 53

Slide 53 text

GDG DevFest
 Incheon 2017 Singleton public class A { private static final A instance = new A(); private A() {} public static A getInstance() { return instance; } public void b() { System.out.println("Singleton"); } } Java // Use A.getInstance().b()

Slide 54

Slide 54 text

GDG DevFest
 Incheon 2017 Singleton object A { fun b() { println("Singleton") } } Kotlin // Use A.b()

Slide 55

Slide 55 text

GDG DevFest
 Incheon 2017 Smart Casts if (obj is String) { print(obj.length) } https://kotlinlang.org/docs/reference/typecasts.html#smart-casts

Slide 56

Slide 56 text

GDG DevFest
 Incheon 2017 Smart Casts if (obj is String) { print(obj.length) } Type Check https://kotlinlang.org/docs/reference/typecasts.html#smart-casts

Slide 57

Slide 57 text

GDG DevFest
 Incheon 2017 Smart Casts if (obj is String) { print(obj.length) } Smart Casts https://kotlinlang.org/docs/reference/typecasts.html#smart-casts

Slide 58

Slide 58 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) }

Slide 59

Slide 59 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } Type Check

Slide 60

Slide 60 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } Smart Casts

Slide 61

Slide 61 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } Type Check

Slide 62

Slide 62 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } Smart Casts

Slide 63

Slide 63 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } Type Check

Slide 64

Slide 64 text

GDG DevFest
 Incheon 2017 Smart Casts when (x) { is Int -> print(x + 1) is String -> print(x.length + 1) is IntArray -> print(x.sum()) } Smart Casts

Slide 65

Slide 65 text

GDG DevFest
 Incheon 2017 Extension Function inline fun Fragment.toast(message: CharSequence): Unit = 
 activity.toast(message) fun Context.toast(message: CharSequence) = 
 Toast.makeText(this, message, Toast.LENGTH_SHORT).show() https://github.com/Kotlin/anko/blob/d5a526512b48c5cd2e3b8f6ff14b153c2337aa22/anko/library/ static/commons/src/dialogs/Toasts.kt // Use in Activity/Fragment toast("Hello World")

Slide 66

Slide 66 text

GDG DevFest
 Incheon 2017 fun Context.toast(message: CharSequence) = 
 Toast.makeText(this, message, Toast.LENGTH_SHORT).show() Extension Function

Slide 67

Slide 67 text

GDG DevFest
 Incheon 2017 fun Context.toast(message: CharSequence) = 
 Toast.makeText(this, message, Toast.LENGTH_SHORT).show() Extension Function Receiver Type

Slide 68

Slide 68 text

GDG DevFest
 Incheon 2017 fun Context.toast(message: CharSequence) = 
 Toast.makeText(this, message, Toast.LENGTH_SHORT).show() Extension Function Function Definition

Slide 69

Slide 69 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas fun List.map(transform: (T) -> R): List { val result = arrayListOf() for (item in this) result.add(transform(item)) return result }

Slide 70

Slide 70 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas fun List.map(transform: (T) -> R): List { val result = arrayListOf() for (item in this) result.add(transform(item)) return result } Function Type

Slide 71

Slide 71 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas val list = listOf(1, 2, 3) list.map({ x: Int -> x * 2 })

Slide 72

Slide 72 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas val list = listOf(1, 2, 3) list.map({ x: Int -> x * 2 }) list.map({ x -> x * 2 })

Slide 73

Slide 73 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas val list = listOf(1, 2, 3) list.map({ x: Int -> x * 2 }) list.map({ x -> x * 2 }) list.map() { x -> x * 2 }

Slide 74

Slide 74 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas val list = listOf(1, 2, 3) list.map({ x: Int -> x * 2 }) list.map({ x -> x * 2 }) list.map() { x -> x * 2 } list.map { x -> x * 2 }

Slide 75

Slide 75 text

GDG DevFest
 Incheon 2017 Higher-Order Functions and Lambdas val list = listOf(1, 2, 3) list.map({ x: Int -> x * 2 }) list.map({ x -> x * 2 }) list.map() { x -> x * 2 } list.map { x -> x * 2 } list.map { it * 2 }

Slide 76

Slide 76 text

GDG DevFest
 Incheon 2017 Scope apply also run/with let

Slide 77

Slide 77 text

GDG DevFest
 Incheon 2017 Scope (apply, also, run, let) Aࠗఠ Zө૑ ޙ੗ৌਸ ٜ݅যࠇद׮

Slide 78

Slide 78 text

GDG DevFest
 Incheon 2017 Scope (apply, also, run, let) val result = StringBuilder().apply { for (letter in 'A'..'Z') { append(letter) } } apply ‣ this : StringBuilder() ‣ return : ഐ୹ೠ Receiver

Slide 79

Slide 79 text

GDG DevFest
 Incheon 2017 val result = StringBuilder().also { for (letter in 'A'..'Z') { it.append(letter) } } Scope (apply, also, run, let) also ‣ it : StringBuilder() ‣ return : ഐ୹ೠ Receiver

Slide 80

Slide 80 text

GDG DevFest
 Incheon 2017 Scope (apply, also, run, let) val result = StringBuilder().run { for (letter in 'A'..'Z') { append(letter) } this } run ‣ this : StringBuilder() ‣ return : Block ݃૑݄ ઴

Slide 81

Slide 81 text

GDG DevFest
 Incheon 2017 val result = StringBuilder().let { for (letter in 'A'..'Z') { it.append(letter) } it } Scope (apply, also, run, let) let ‣ it : StringBuilder() ‣ return : Block ݃૑݄ ઴

Slide 82

Slide 82 text

GDG DevFest
 Incheon 2017 Scope this it self apply also result run/with let

Slide 83

Slide 83 text

GDG DevFest
 Incheon 2017 Collections Immutable Mutable listOf mutableListOf mapOf hashMapOf setOf hashSetOf

Slide 84

Slide 84 text

GDG DevFest
 Incheon 2017 Collections val numbers: MutableList = mutableListOf(1, 2, 3) val readOnlyView: List = numbers println(numbers) // prints "[1, 2, 3]" numbers.add(4) println(readOnlyView) // prints "[1, 2, 3, 4]" readOnlyView.clear() // -> does not compile https://kotlinlang.org/docs/reference/collections.html

Slide 85

Slide 85 text

GDG DevFest
 Incheon 2017 Collections val _items = mutableListOf() val items: List = _items.toList() // Convert Immutable val mutableItems = items.toMutableList() // Convert Mutable

Slide 86

Slide 86 text

GDG DevFest
 Incheon 2017 Collections val items = listOf(1, 2, 3, 4) items.first() == 1 items.last() == 4 items.filter { it % 2 == 0 } // returns [2, 4] val rwList = mutableListOf(1, 2, 3) rwList.requireNoNulls() // returns [1, 2, 3] if (rwList.none { it > 6 }) println("No items above 6”) // prints "No items above 6" val item = rwList.firstOrNull() https://kotlinlang.org/docs/reference/collections.html

Slide 87

Slide 87 text

GDG DevFest
 Incheon 2017 Collections Iterable MutableIterable MutableCollection MutableList MutableSet Collection List Set ArrayList ArrayList Read-only interface Mutable interface Java classes

Slide 88

Slide 88 text

GDG DevFest
 Incheon 2017 Type aliases data class User(val name: String, val job: String) typealias Pluu = User println(User("Pluu", "Developer")) // User(name=Pluu, job=Developer) println(Pluu("Pluu", "Developer")) // User(name=Pluu, job=Developer)

Slide 89

Slide 89 text

GDG DevFest
 Incheon 2017 Type aliases typealias PluuList = List val list : PluuList = listOf( User("User Name", "Test1"), Pluu("Pluu Name", "Test2") ) println(list) // [User(name=User Name, job=Test1), User(name=Pluu Name, job=Test2)]

Slide 90

Slide 90 text

GDG DevFest
 Incheon 2017 Type aliases typealias Predicate = (T) -> Boolean fun foo(p: Predicate) = p(42) fun main(args: Array) { val f: (Int) -> Boolean = { it > 0 } println(foo(f)) // prints "true" val p: Predicate = { it > 0 } println(listOf(1, -2).filter(p)) // prints "[1]" }

Slide 91

Slide 91 text

GDG DevFest
 Incheon 2017 KOTLIN FOR ANDROID

Slide 92

Slide 92 text

GDG DevFest
 Incheon 2017 Android Studio 3.0 https://developer.android.com/kotlin/get-started.html

Slide 93

Slide 93 text

GDG DevFest
 Incheon 2017 Android Studio 3.0 https://developer.android.com/kotlin/get-started.html

Slide 94

Slide 94 text

GDG DevFest
 Incheon 2017 Android Studio 3.0 ▸ Tools > Kotlin > Configure Kotlin in Project

Slide 95

Slide 95 text

GDG DevFest
 Incheon 2017 Project Configuration buildscript { ext.kotlin_version = '1.1.51' repositories { …… } dependencies { classpath ‘com.android.tools.build:gradle: 3.0.0-rc2' classpath "org.jetbrains.kotlin:kotlin- gradle-plugin:$kotlin_version" } } apply plugin: ‘kotlin-android' dependencies { compile "org.jetbrains.kotlin:kotlin- stdlib-jre7:$kotlin_version" } project build.gradle app build.gradle

Slide 96

Slide 96 text

GDG DevFest
 Incheon 2017 Kotlin Android Extensions app build.gradle apply plugin: 'kotlin-android-extensions' import kotlinx.android.synthetic.main..* // kotlinx.android.synthetic.main.activity_main.*

Slide 97

Slide 97 text

GDG DevFest
 Incheon 2017 Kotlin Android Extensions import kotlinx.android.synthetic.main.activity_main.* class MyActivity : Activity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) textView.setText("Hello, world!") } } Kotlin Android Extensions

Slide 98

Slide 98 text

GDG DevFest
 Incheon 2017 Kotlin Android Extensions ~ Parcelable Support public class MyParcelable implements Parcelable { private int mData; public int describeContents() { return 0; } public void writeToParcel(Parcel out, int flags) { out.writeInt(mData); } public static final Parcelable.Creator CREATOR = new Parcelable.Creator() { public MyParcelable createFromParcel(Parcel in) { return new MyParcelable(in); } public MyParcelable[] newArray(int size) { return new MyParcelable[size]; } }; private MyParcelable(Parcel in) { mData = in.readInt(); } } https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md

Slide 99

Slide 99 text

GDG DevFest
 Incheon 2017 Kotlin Android Extensions ~ Parcelable Support build.gradle apply plugin: 'kotlin-android-extensions' androidExtensions { experimental = true }

Slide 100

Slide 100 text

GDG DevFest
 Incheon 2017 Kotlin Android Extensions ~ Parcelable Support @Parcelize class MyParcelable(val data: Int): Parcelable https://github.com/Kotlin/KEEP/blob/master/proposals/extensions/android-parcelable.md

Slide 101

Slide 101 text

GDG DevFest
 Incheon 2017 CHOICE

Slide 102

Slide 102 text

GDG DevFest
 Incheon 2017 ੺ݎಞ ‣ ۞׬ழ࠳ ‣ Functional Programming ‣ Hybrid Language о о૑ח ޙઁٜ ‣ ೠӖ ೠӖ ೠӖ

Slide 103

Slide 103 text

GDG DevFest
 Incheon 2017 ੺ݎಞ ~ Overhead ▸ Kotlin Compiler ী ੄೧ ࢤࢿغח ௏٘ ▸ ࢤпೞח Ѫࠁ׮ ؊ ݆਷ ௏٘о ࢤࢿ ▸ ೞ૑݅, ೙ਃदী ٜ݅যঠೞח ௏٘ ▸ ms ױਤ ର੉ ▸ Javaࠁ׮ וܽѪ਷ ಂ౟

Slide 104

Slide 104 text

GDG DevFest
 Incheon 2017 ੺ݎಞ ~ Overhead fun test(x: Any) { if (x is String) { println(x.length) println(x.length) println(x.length) println(x.length) } } public static final void test(@NotNull Object x) { Intrinsics.checkParameterIsNotNull(x, "x"); if (x instanceof String) { int var1 = ((String)x).length(); System.out.println(var1); var1 = ((String)x).length(); System.out.println(var1); var1 = ((String)x).length(); System.out.println(var1); var1 = ((String)x).length(); System.out.println(var1); } } Kotlin Decompile

Slide 105

Slide 105 text

GDG DevFest
 Incheon 2017 ੺ݎಞ ~ kapt ▸ Kotlin plugin supports annotation processors like Dagger or DBFlow. ▸ kotlinc ▶︎ Kotlin Stubs ▶︎ javac ▶︎ Final Code ▸ Clean Build ೧ঠ૑ ઁ؀۽ ز੘ೞӝب ೣ ▸ ঌ ࣻ হח ী۞

Slide 106

Slide 106 text

GDG DevFest
 Incheon 2017 ੺ݎಞ ~ ੗߄৬੄ ੉߹਷ ࠛоמ ▸ Framework Ú Java ▸ Library Ú Java / Kotlin ▸ Your Code Ú Java / Kotlin ▸ Kotlin Compilerо Java Class Codeܳ ݅ٞ ▸ Java to Kotlin, non-null ё୓ী null ਸ ࠁյ ҃਋ …. ী۞ ߊࢤ

Slide 107

Slide 107 text

GDG DevFest
 Incheon 2017 ൞ݎಞ ‣ Java ޙઁ ೧Ѿ ‣ Kotlin Android Extensions ‣ טযաח Kotlin ‣ Simple is Best ‣ Support Jetbrains

Slide 108

Slide 108 text

GDG DevFest
 Incheon 2017 ൞ݎಞ ~ Java ޙઁ ೧Ѿ Java 6 2006 Java 7 2011 Java 8 2014 Android 1.0 2008 Java 7 Support 2013 Java 8 Support Jack / desugar Different for every version Java 9 ????

Slide 109

Slide 109 text

GDG DevFest
 Incheon 2017 ൞ݎಞ ~ Java ޙઁ ೧Ѿ

Slide 110

Slide 110 text

GDG DevFest
 Incheon 2017 https://developer.android.com/about/dashboards/index.html

Slide 111

Slide 111 text

GDG DevFest
 Incheon 2017 ൞ݎಞ ~ טযաח Kotlin ▸ ࠶۽Ӓ / ߊ಴ / ҳӖ ࢠ೒ী Kotlin ࢎਊ੉ ૐо ▸ ӝઓ Java 100% ▶︎ Java (N %) + Kotlin (M %) ▸ ׮೯൤, ೠӖ۽ ੘ࢿغח Ӗٜ੉ ࢤӝҊ ੓਺ ▸ ٘٣য, ೠӖ۽ ػ ଼ 1ӂ੉ ୹द ▸ ழפ੄ ௏ౣܽ (୹द ৘੿)

Slide 112

Slide 112 text

GDG DevFest
 Incheon 2017 Simple is Beset ▸ Delegation ▸ Data Class ▸ Singleton ▸ Null Safety ▸ Expression ▸ Destructuring Declarations ▸ Type Checks and Casts

Slide 113

Slide 113 text

GDG DevFest
 Incheon 2017 ൞ݎಞ ~ Support Jetbrains ▸ Show Kotlin Bytecode ▶︎ Decompile ▸ Decompile ػ Java ௏٘۽ ୓௼ оמ

Slide 114

Slide 114 text

GDG DevFest
 Incheon 2017 Realm Report Q4 2017 Java 85.3% Kotlin 14.7% 2017/09/25 Java 49.3% Kotlin 50.7% 2018/12/10

Slide 115

Slide 115 text

GDG DevFest
 Incheon 2017 http://tech.lezhin.com/2017/08/03/the-case-against-kotlin

Slide 116

Slide 116 text

GDG DevFest
 Incheon 2017 ֢য়য়য়য়য়য়۱ ೧ঠೠ׮

Slide 117

Slide 117 text

GDG DevFest
 Incheon 2017

Slide 118

Slide 118 text

GDG DevFest
 Incheon 2017 ଵҊ ▸ Kotlin Reference (https://kotlinlang.org/docs/reference/) ▸ Get Started with Kotlin — It is here to stay (https://medium.com/peachstudio/get-started- with-kotlin-it-is-here-to-stay-1eaac85ae6a0) ▸ Kotlin: A New Hope in a Java 6 Wasteland (https://academy.realm.io/posts/droidcon- michael-pardo-kotlin/) ▸ Kotlin੄ ࡄҗ Ӓܿ੗ (http://tech.lezhin.com/2017/08/03/the-case-against-kotlin) ▸ Beyond Kotlin - Advanced features for API Makers (https://speakerdeck.com/agiuliani/ beyond-kotlin-advanced-features-for-api-makers) ▸ Develop your next app with Kotlin - AndroidRennes 2017 (https://speakerdeck.com/agiuliani/ develop-your-next-app-with-kotlin-androidrennes-2017)

Slide 119

Slide 119 text

GDG DevFest
 Incheon 2017 Q&A GDG Slack #android #kotlin (Slack : http://slack.gdg.kr/)