Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up
for free
Kotlin Everywhere
Roberto Orgiu
July 20, 2018
Technology
0
27
Kotlin Everywhere
Roberto Orgiu
July 20, 2018
Tweet
Share
More Decks by Roberto Orgiu
See All by Roberto Orgiu
tiwiz
0
10
tiwiz
0
10
tiwiz
1
18
tiwiz
2
73
tiwiz
0
43
tiwiz
1
48
tiwiz
0
85
tiwiz
1
86
tiwiz
0
11
Other Decks in Technology
See All in Technology
clustervr
0
210
layerx
1
930
con_mame
4
2k
cygames
1
410
ishiayaya
PRO
0
340
greymd
0
630
saoritakita
0
350
takapi86
0
140
yosuke_furukawa
PRO
47
16k
hamadakoji
1
1.1k
recruitengineers
0
110
muras
0
110
Featured
See All Featured
mongodb
23
3.8k
nonsquared
81
3.3k
pedronauck
652
110k
jnunemaker
PRO
40
4.6k
stephaniewalter
260
11k
holman
461
280k
garrettdimon
287
110k
qrush
285
18k
marcelosomers
220
15k
mza
80
4.1k
samanthasiow
56
6.3k
afnizarnur
176
14k
Transcript
Kotlin everywhere
Who’s speaking Rob @ NYT Boris @ ClearScore 2
#CPIT2 sli.do Join the discussion
Where https://pusher.com/state-of-kotlin
Desktop apps with a little bit of Tornado™
• JavaFX • Beautiful DSL • UI + Background thread
• Injection • REST • Field validation • Can work™ with JS TornadoFX 6
tornadofx.io goo.gl/qSjBPG goo.gl/gcrZss
iOS apps and Android (but we wanted the WOW moment)
Kotlin Native COMMON no platform specific dependencies class/function declaration 9
PLATFORM implementations of platform-dependent declarations in the common module always an implementation of a single common module REGULAR targets specific platform can be dependency of platform modules can depend on platform modules
10
◇ common module defines expected declarations ◇ expected declarations never
contain any implementation code 11 expected
12 actual ◇ platform module provides actual declarations ◇ actual
declarations must match expected declarations
13 package org.jetbrains.foo expect class Foo(bar: String) { fun frob()
} fun main(args: Array<String>) { Foo("Hello").frob() }
14 package org.jetbrains.foo actual class Foo actual constructor(val bar: String)
{ actual fun frob() { println("Frobbing the $bar") } }
JVM Backend
16
Javascript Both Frontend and Backend!
18
19
◇ You can set and call everything you want on
properties of this type ◇ Disables compiler checks (beware of runtime errors) 20 dynamic
◇ Kotlin assumes the implementation is provided by the developer
(in JS) ◇ The compiler will not generate JS code for this function ◇ No auto completion 21 external
22 external fun require(module: String): dynamic fun main(args: Array<String>) {
val app = require(“express”) app.get(“/hello”, {req, res -> res.send(“Hello world!”) }) }
} 23 { Kotlin wrappers
24 @JsModule(“express”) external class Express { fun get( route: String,
callback: (req: Request, res: Response) -> Unit ) external class Request external class Response { fun send(data: String) } }
} 25 { Kotlin wrappers https://github.com/JetBrains/kotlin-wrappers
Thanks! Any questions? You can find us at: ◇ @_tiwiz
◇ @borisdamato 26