KotlinConf Sharing [Kotlin code across platforms] is caring! Eugenio Marletti @workingkills
“ ” ” “ “ ” ” “ “app”
“ “ “ ” ” ” “ “app” ” iOS Android frontend backend tools
sharing
sharing code
sharing code
sharing business logic
sharing bugs
sharing bugs
sharing fixes
sharing effort
C++ J2ObjC / GWT JavaScript
THE ALGORITHM™
C++ ObjC++ THE ALGORITHM™ JavaScript TypeScript
C++ ObjC++ JavaScript iOS !" JavaScriptCore TypeScript Android !" WebView
̺ ̨͇̯ ̔̍̀̏̌̕ ̵ ͒ ̘͖̯ C++ ObjC++ JavaScript ͔͎̗̬̼̓̒̄̍̓͐̒̎̕ b ̡̫̰͙͚͋͋̓́̇͟ V ͐̇͞ ̓̿̔̿̓ ̚ iOS !" JavaScriptCore TypeScript w ̛͊͆̍͑ i ͒̅̉͊̌̇ ͟ ̨̭̳̱͕ Android !" W ͊̊̏̃͑̽̃̕ ̶ȩ̧̟̝͔ ̯̦ę͕͔͉̜̗͔͎ ̴̯̯̻̪̦ ̡͓̰̲̳͟ ̥̯ ͢ ͟
C++ ObjC++ JavaScript iOS !" JavaScriptCore TypeScript Android !" ?
C++ ObjC++ JavaScript THE ALGORITHM™ TypeScript Florent Bécart Kotlin @fbecart
multi-platform
(before 1.2) -Xmulti-platform header impl
(before 1.2) -Xmulti-platform header impl
(from 1.2) -Xmulti-platform expect actual
ANDROID WebView legacy.js BACKEND JS iOS JavaScriptCore
ANDROID WebView shared.kt legacy.js BACKEND JS iOS JavaScriptCore shared-test.kt legacy-test.js
ANDROID WebView shared.kt legacy.js BACKEND JS iOS JavaScriptCore shared-test.kt legacy-test.js
ANDROID WebView shared.kt legacy.js BACKEND JS iOS JavaScriptCore shared-test.kt legacy-test.js
ANDROID WebView shared.kt legacy.js BACKEND JS iOS JavaScriptCore shared-test.kt legacy-test.js
ANDROID WebView JVM shared.kt BACKEND JS iOS JavaScriptCore shared-test.kt legacy-test.js
/** * A day number, offset from 01/01/2012 !" export type Day = number
/** * A day number, offset from 01/01/2012 !" typealias Day = Int
export class Value { class Value { constructor(value) { constructor(value: Double) { this.value = value this.value = value } } readonly value: number val value: Double toString() { override fun toString(): String { return String(this.value) return this.value.toString() } } companion object { static add = (v1 : Value, v2 : Value): Value !$ { fun add(v1 : Value, v2 : Value): Value { return new Value(v1.value + v2.value) return Value(v1.value + v2.value) } } static isZero = (valueWithVariance: Value): boolean !$ { fun isZero(valueWithVariance: Value): Boolean { return 0 !!% valueWithVariance.value return .0 !!% valueWithVariance.value } } static subtract = (v1 : Value, v2 : Value): Value !$ { fun subtract(v1 : Value?, v2 : Value?): Value { let value = 0 var value = .0 if (v1 !& v2) { value = v1.value - v2.value } if (v1 !' null !& v2 !' null) { value = v1.value - v2.value } return new Value(value) return Value(value) } } } } }
< insert more talking here >
Eugenio Marletti @workingkills BIT.LY/SHARING-KOTLIN-IS-CARING
Recommend
More recommend