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
Hello Kotlin Js
Search
mattak
October 28, 2015
Programming
0
760
Hello Kotlin Js
My first impression of kotlin js.
mattak
October 28, 2015
Tweet
Share
More Decks by mattak
See All by mattak
最近やった作業環境改善施策10個
mattak
0
260
UnixTime is Simple
mattak
0
200
おっさんが停滞しないために
mattak
32
18k
tech invest
mattak
1
310
Nodux - node base redux framework
mattak
0
1.4k
what_is_technical_investment
mattak
0
130
unitypackage distribution
mattak
0
810
Unity energy usage
mattak
0
910
Unidux 0.3.1
mattak
1
400
Other Decks in Programming
See All in Programming
FormFlow - Build Stunning Multistep Forms
yceruto
1
190
なぜ「共通化」を考え、失敗を繰り返すのか
rinchoku
1
420
AWS CDKの推しポイント 〜CloudFormationと比較してみた〜
akihisaikeda
3
300
童醫院敏捷轉型的實踐經驗
cclai999
0
130
データベースコネクションプール(DBCP)の変遷と理解
fujikawa8
1
270
Blazing Fast UI Development with Compose Hot Reload (droidcon New York 2025)
zsmb
1
150
コード書くの好きな人向けAIコーディング活用tips #orestudy
77web
3
330
Beyond Portability: Live Migration for Evolving WebAssembly Workloads
chikuwait
0
390
なんとなくわかった気になるブロックテーマ入門/contents.nagoya 2025 6.28
chiilog
1
160
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
3
1k
What Spring Developers Should Know About Jakarta EE
ivargrimstad
0
160
A2A プロトコルを試してみる
azukiazusa1
2
980
Featured
See All Featured
Scaling GitHub
holman
459
140k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
10
920
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
32
5.9k
Practical Orchestrator
shlominoach
188
11k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
124
52k
Visualization
eitanlees
146
16k
Making the Leap to Tech Lead
cromwellryan
134
9.3k
Embracing the Ebb and Flow
colly
86
4.7k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
16
940
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
281
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Transcript
Kotlin Js ͞ΘͬͯΈͨ (PUBOEBKT !NBUUBL
Kotlinʁ
ܕ҆શ, JVMݴޠ
Androidʹ͓͚Δ SwiftͬΆ͍ݴޠ Androidք۾ͩͱ Better Javaͳ։ൃݴޠͱͯ͠ɺྲྀߦΓग़ͯ͠Δ
Kotlin.jsͱʁ
JVMܥͷAlt JSݴޠͰ͢ - ੩的型付け - 型安全、Null安全 - Kotlinライブラリが使える - クライアント/サʔバʔがKotlinで書ける
- JetBrainsが作ってるのでEditorサポʔトが早い! ࢀߟIUUQZZZBOLCMPHTQPUKQLPUMJOBMUKTLPUMJOIUNM
type safeʹ html͕͔͚ͨΓ͢Δ ࢀߟ: https://kotlinlang.org/docs/reference/type-safe-builders.html
͍ํ - ύλʔϯ1. gradle -
1. SDKMan $ curl -s get.sdkman.io | bash
2. gradle install $ sdk use gradle 2.8
buildscript { ext.kotlin_version = '1.0.0-beta-1038' repositories { mavenCentral() } dependencies
{ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: "kotlin2js" repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-js-library:$kotlin_version" } compileKotlin2Js.kotlinOptions.sourceMap = true compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/app.js" compileKotlin2Js.kotlinOptions.suppressWarnings = true compileKotlin2Js.kotlinOptions.verbose = true task copyJsFilesFromDependencies(dependsOn: build) { configurations.compile.each { File file -> copy { includeEmptyDirs = false from zipTree(file.absolutePath) into "${projectDir}/web/js/lib" include { fileTreeElement -> def path = fileTreeElement.path path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/")) } } } }
buildscript { ext.kotlin_version = '1.0.0-beta-1038' repositories { mavenCentral() } dependencies
{ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } apply plugin: "kotlin2js" repositories { mavenCentral() } dependencies { compile "org.jetbrains.kotlin:kotlin-js-library:$kotlin_version" } compileKotlin2Js.kotlinOptions.sourceMap = true compileKotlin2Js.kotlinOptions.outputFile = "${projectDir}/web/js/app.js" compileKotlin2Js.kotlinOptions.suppressWarnings = true compileKotlin2Js.kotlinOptions.verbose = true task copyJsFilesFromDependencies(dependsOn: build) { configurations.compile.each { File file -> copy { includeEmptyDirs = false from zipTree(file.absolutePath) into "${projectDir}/web/js/lib" include { fileTreeElement -> def path = fileTreeElement.path path.endsWith(".js") && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/")) } } } } 3. build.gradleॻ͘
4. ίʔυॻ͘
5. build͢Δ $ gradle clean build
ίʔυ͕ग़ྗ͞ΕΔ
σΟϨΫτϦߏ $ find . -type f . ├── build.gradle ├──
src │ └── main │ └── kotlin │ └── me │ └── mattak │ └── example │ └── kotlinjs │ └── main.kt └── web ├── index.html └── js ├── app.js ├── app.js.map └── lib ├── kotlin.js └── stdlib.meta.js
͍ํ - ύλʔϯ2. homebrew -
1. brew install $ brew install kotlin
2. ίʔυΛॻ͘
3. convert͢Δ $ kotlinc-js main.kt -output main.js
ίʔυ͕ग़ྗ͞ΕΔ
͍ํ - ύλʔϯ3. ΏͱΓΉ͚ -
try.kotlinlang.org
ͦͷଞಛ
Q. ϥϯλΠϜͷαΠζ ͱ͔େ͖͍ΜͰ͠ΐ͏ʁ
A. ͏Μ $ ls -lha web/js/lib/ total 1912 drwxr-xr-x 4
mattak staff 136B 10 27 17:39 . drwxr-xr-x 3 mattak staff 102B 10 27 17:39 .. -rw-r--r-- 1 mattak staff 804K 10 27 17:39 kotlin.js -rw-r--r-- 1 mattak staff 146K 10 27 17:39 stdlib.meta.js minifyͯ͠ͳ͍͚Ͳ jsͷϥΠϒϥϦͱͯ݁͠ߏαΠζͰ͔͍
Q. JavaͷϥΠϒϥϦ ͱ͔ݺͼग़ͤΔͷʁ
A. Ұ෦Αͼͩͤ·͢
Q. طଘͷJsͷϥΠϒ ϥϦͱ࿈ܞͰ͖Δͷʁ
A. native annotaionͰఆٛॻ͚ ͔ͭ͑ΔͬΆ͍ ࢀߟ: http://www.slideshare.net/mikeneck/kotlin-as-an-altjs/19
Q. ࣮༻తʁ
A. ͦΜͳ࣮༻త͡Όͳ͍͔ - js系の他の文化とあんまり親和してない - javaの資࢈もあんまり活きてない - Alt JSな型安全言語では、TypeScriptのほうが࣮用的かも
݁ - ݱঢ়ͩͱ͓ͪΌͰɺ࣮༻తͰͳ͍͔ - ͋ͱࠓnpm͔ΒཧͰ͖ͳ͍Α - type safe html builderͱ͔໘നͦ͏
αϯϓϧͱ͔ https://github.com/mattak/KotlinJsSample