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
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
ふつうのFeature Flag実践入門
irof
7
3.9k
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
4.2k
並列実装の現場、2ヶ月間実務でAIを使い倒したAIもPCも私も限界が近い
ming_ayami
0
130
RTSPクライアントを自作してみた話
simotin13
0
600
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.1k
Honoでのサプライチェーン侵害対策 〜 3つのライブラリに学ぶ
yusukebe
4
740
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
190
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
170
Go1.27で導入されるジェネリクスメソッドでできること
mackee
0
120
Vite+ Unified Toolchain for the Web
naokihaba
0
300
ローカルLLMを使ってB2Bサービスを作っていての学び
yaotti
0
170
New "Type" system on PicoRuby
pocke
1
920
Featured
See All Featured
Agile that works and the tools we love
rasmusluckow
331
21k
Building AI with AI
inesmontani
PRO
1
1.1k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
720
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
140
First, design no harm
axbom
PRO
2
1.2k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
287
14k
Automating Front-end Workflow
addyosmani
1370
210k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.6k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.5k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
201
75k
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