Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin Beyond Android: 2019
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
Guillermo Orellana
November 25, 2019
Programming
410
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin Beyond Android: 2019
Guillermo Orellana
November 25, 2019
More Decks by Guillermo Orellana
See All by Guillermo Orellana
All stacks Kotlin
wiyarmir
1
560
Full Stack Kotlin
wiyarmir
2
400
Kotlin beyond Android
wiyarmir
2
340
"Bring your Kotlin to Work" Day
wiyarmir
1
1.6k
Other Decks in Programming
See All in Programming
才能?センス?知らん、 続けたもん勝ちだ。-- 結婚・出産・癌を越えてなお、私がプロダクトを創り続ける理由
16bitidol
2
790
OSINT for SRE: 学術論文とポストモーテムから探る システム障害の共通パターン / SRE NEXT 2026
tomoyk
1
2.5k
地域 SRE コミュニティ最前線 - ホンマでっかSRE勉強会
tk3fftk
0
160
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
290
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
180
【やさしく解説 設計編 #0】DDDのコード、読めるのに分からない人へ
panda728
PRO
1
230
アルゴリズムは何を圧縮しているのか ─ Haskell から育った「圧縮代数」というメンタルモデル
naoya
14
2.9k
どこまでゆるくて許されるのか
tk3fftk
0
420
AIエージェントで 変わるAndroid開発環境
takahirom
1
450
はてなアカウント基盤 State of the Union
cockscomb
1
1.3k
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
120
The Bowling Game- From Imperative to Functional Programming - Part 1
philipschwarz
PRO
0
290
Featured
See All Featured
Are puppies a ranking factor?
jonoalderson
1
3.7k
Tell your own story through comics
letsgokoyo
1
990
<Decoding/> the Language of Devs - We Love SEO 2024
nikkihalliwell
1
270
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
1k
Docker and Python
trallard
47
3.9k
My Coaching Mixtape
mlcsv
0
170
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
sira's awesome portfolio website redesign presentation
elsirapls
0
300
Faster Mobile Websites
deanohume
310
32k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
63
55k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
The untapped power of vector embeddings
frankvandijk
2
1.8k
Transcript
Kotlin Beyond Android Guillermo Orellana @wiyarmir November 2019 Droidcon San
Francisco
None
We are in the US! And we are hiring in
Los Angeles! Backend, iOS, Android
None
None
None
None
Ctrl+Shift+Alt+K ⌘+⇧+⌥+K
None
None
Backend
None
fun main(args: Array<String>) { embeddedServer(Netty, 8080) { routing { get("/")
{ call.respondText("Hello World") } } }.start() } http://ktor.io/
API Tests #
@Test fun `when userId and password provided then user is
created`() = testApp(mockStorage) { handleRequest(HttpMethod.Post, endpoint) { addHeader( HttpHeaders.ContentType, ContentType.Application.FormUrlEncoded.toString() ) setBody( listOf( "userId" to testId, "password" to testPassword ).formUrlEncode() ) }.apply { assertThat(response.status(), equalTo(HttpStatusCode.Created)) }
Deploying
None
$ git push heroku master
Counting objects: 155, done. Delta compression using up to 36
threads. Compressing objects: 100% (50/50), done. Writing objects: 100% (89/89), 17.45 KiB | 0 bytes/s, done. Total 89 (delta 33), reused 75 (delta 19) remote: -----> Cleaning up!!... remote: -----> Building keynotedex from herokuish!!... remote: -----> Adding BUILD_ENV to build environment!!... remote: -----> Gradle app detected remote: -----> Installing JDK 1.8!!... done remote: -----> Building Gradle app!!... remote: -----> executing ./gradlew stage remote: To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https:!//docs.gradle.org/4.10.2/userguide/gradle_daemon.html. remote: Daemon will be stopped at the end of the build stopping after processing remote: > Task :buildSrc:discoverMainScriptsExtensions remote: > Task :buildSrc:compileKotlin remote: > Task :buildSrc:compileJava NO-SOURCE remote: > Task :buildSrc:compileGroovy NO-SOURCE remote: > Task :buildSrc:processResources NO-SOURCE remote: > Task :buildSrc:classes UP-TO-DATE remote: > Task :buildSrc:inspectClassesForKotlinIC remote: > Task :buildSrc:jar remote: > Task :buildSrc:assemble remote: > Task :buildSrc:discoverTestScriptsExtensions remote: > Task :buildSrc:compileTestKotlin NO-SOURCE remote: > Task :buildSrc:compileTestJava NO-SOURCE remote: > Task :buildSrc:compileTestGroovy NO-SOURCE remote: > Task :buildSrc:processTestResources NO-SOURCE remote: > Task :buildSrc:testClasses UP-TO-DATE remote: > Task :buildSrc:test NO-SOURCE remote: > Task :buildSrc:check UP-TO-DATE remote: > Task :buildSrc:build remote: > Task :backend:clean UP-TO-DATE remote: > Task :backend:discoverMainScriptsExtensions remote: > Task :common:compileJava NO-SOURCE remote: > Task :common:compileKotlinCommon remote: > Task :common:processResources NO-SOURCE remote: > Task :common:classes remote: > Task :common:inspectClassesForKotlinIC remote: > Task :common:jar remote: > Task :common-jvm:discoverMainScriptsExtensions remote: > Task :common-jvm:compileKotlin
remote: > Task :web:runDceKotlinJs remote: > Task :web:compileJava NO-SOURCE remote:
> Task :web:classes remote: > Task :web:compileTestKotlin2Js NO-SOURCE remote: > Task :web:runDceTestKotlinJs NO-SOURCE remote: > Task :web:webpack-config remote: > Task :web:webpack-helper SKIPPED remote: > Task :web:webpack-bundle remote: > Task :web:bundle remote: > Task :web:inspectClassesForKotlinIC remote: > Task :web:jar remote: > Task :web:assemble remote: > Task :web:karma-config SKIPPED remote: > Task :web:karma-run-single SKIPPED remote: > Task :web:compileTestJava NO-SOURCE remote: > Task :web:testClasses UP-TO-DATE remote: > Task :web:test NO-SOURCE remote: > Task :web:check UP-TO-DATE remote: > Task :web:build remote: > Task :backend:copyWebBundle remote: > Task :backend:processReleaseResources remote: > Task :backend:releaseClasses remote: > Task :backend:releaseJar remote: > Task :backend:release remote: > Task :stage remote: remote: Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0. remote: Use '!--warning-mode all' to show the individual deprecation warnings. remote: See https:!//docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings remote: remote: BUILD SUCCESSFUL in 9m 8s remote: 32 actionable tasks: 31 executed, 1 up-to-date remote: w: Detected multiple Kotlin daemon sessions at build/kotlin/sessions remote: -----> Discovering process types remote: Procfile declares types !-> web remote: -----> Releasing keynotedex (dokku/keynotedex:latest)!!... remote: -----> Deploying keynotedex (dokku/keynotedex:latest)!!... remote: -----> Attempting to run scripts.dokku.predeploy from app.json (if defined) remote: -----> App Procfile file found (/home/dokku/keynotedex/DOKKU_PROCFILE) remote: -----> DOKKU_SCALE file found (/home/dokku/keynotedex/DOKKU_SCALE) remote: =====> web=1 remote: -----> Attempting pre-!flight checks remote: -----> Attempt 1/5 Waiting for 5 seconds !!...
$ git push origin master $ git push heroku master
None
$ git push origin master
None
None
None
Web
override fun HTML.apply() { head { meta { charset =
"utf-8" } meta { name = "viewport" content = "width=device-width, initial-scale=1.0" } title { insert(caption) } insert(head) } body { div { id = "content" }
override fun HTML.apply() { head { meta { charset =
"utf-8" } meta { name = "viewport" content = "width=device-width, initial-scale=1.0, shrink-to-fit=no" } title { +"Keynotedex" } insert(head) link( rel = LinkRel.stylesheet, type = LinkType.textCss, href = "https:!//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" ) { attributes["integrity"] = "sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" attributes["crossorigin"] = "anonymous" } } body { div { id = "content" } script(src = "https:!//code.jquery.com/jquery-3.2.1.slim.min.js") { attributes["integrity"] = "sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" attributes["crossorigin"] = "anonymous" } script(src = "https:!//cdnjs.cloud!flare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js") { attributes["integrity"] = "sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" attributes["crossorigin"] = "anonymous" } script(src = "https:!//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js") { attributes["integrity"] = "sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" attributes["crossorigin"] = "anonymous" } script { insert(bundle) } }
Kotlin JVM kotlinc
https://en.wikipedia.org/wiki/React_(JavaScript_library)
KotlinJS kotlinc-js
window.onload = { document.getElementById("content") .innerHTML = "Hola" }
dynamic
val a: dynamic = 3 a.`types?` .I.`haven't`.heard .that.name.`in`.years = ")"
https://en.wikipedia.org/wiki/React_(JavaScript_library) +
None
None
Kotlin Native kotlinc-native
None
None
None
None
Kotlin Multiplatform
Multiplatform Modules
MyModule
jvmMain androidMain iosMain jsMain commonMain MyModule
jvmMain androidMain iosMain jsMain commonMain jvmTest androidTest iosTest jsTest commonTest
MyModule
jvmMain androidMain iosMain jsMain commonMain MyModule
jvmMain androidMain iosMain jsMain commonMain
expect / actual
jvmMain androidMain iosMain jsMain commonMain MyModule
Multiplatform libraries
@Serializable data class SubmissionResponse( val submission: Submission )
httpClient.submitForm<SignInResponse>( path = Paths.signIn, formParameters = parametersOf( "userId" to listOf(userId),
"password" to listOf(password) ) )
launch { getUserProfile.execute("user1") .fold( { state = Error(it) }, {
state = Content(it) } ) }
Code sharing
Repository Domain Logic Presentation View Binding UI Network
Repository Domain Logic Presentation View Binding UI Network
Repository Domain Logic Presentation View Binding UI Network
The present
$ curl \ https:!//keynotedex.wiyarmir.es/api/v1/conferences/ \ -H 'accept: application/json'
None
None
None
The future
Kotlin 1.3.60 • New Kotlin Native targets • Symbolication of
iOS crashes • Performance • New JS plugin improvements • Multithreaded native coroutines preview
Multiplatform architecture • Don't just share code, share architectural language
• Kotlin Multiplatform an implementation detail
Wrapping up
Is the tech ready?
None
Judge by yourself
https://keynotedex.wiyarmir.es/
wiyarmir/keynotedex
wiyarmir/kotlin-multiplatform-template
Slides: https://speakerdeck.com/wiyarmir/kotlin-beyond-android-2019 Code: github.com/wiyarmir/keynotedex Templates: github.com/wiyarmir/kotlin-multiplatform-template Contact: twitter.com/@wiyarmir