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
820
Unity energy usage
mattak
0
910
Unidux 0.3.1
mattak
1
400
Other Decks in Programming
See All in Programming
『自分のデータだけ見せたい!』を叶える──Laravel × Casbin で複雑権限をスッキリ解きほぐす 25 分
akitotsukahara
2
660
型で語るカタ
irof
0
700
システム成長を止めない!本番無停止テーブル移行の全貌
sakawe_ee
1
360
The Niche of CDK Grant オブジェクトって何者?/the-niche-of-cdk-what-isgrant-object
hassaku63
1
610
ソフトウェア設計とAI技術の活用
masuda220
PRO
17
3.5k
Porting a visionOS App to Android XR
akkeylab
0
680
Startups on Rails in Past, Present and Future–Irina Nazarova, RailsConf 2025
irinanazarova
0
240
Claude Code派?Gemini CLI派? みんなで比較LT会!_20250716
junholee
1
530
ふつうの技術スタックでアート作品を作ってみる
akira888
1
1.3k
たった 1 枚の PHP ファイルで実装する MCP サーバ / MCP Server with Vanilla PHP
okashoi
1
300
The Evolution of Enterprise Java with Jakarta EE 11 and Beyond
ivargrimstad
0
260
テスト駆動Kaggle
isax1015
1
620
Featured
See All Featured
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
3.9k
How to Ace a Technical Interview
jacobian
278
23k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
53k
Facilitating Awesome Meetings
lara
54
6.5k
YesSQL, Process and Tooling at Scale
rocio
173
14k
Building Adaptive Systems
keathley
43
2.7k
KATA
mclloyd
30
14k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
35
2.4k
Git: the NoSQL Database
bkeepers
PRO
430
65k
Unsuck your backbone
ammeep
671
58k
Become a Pro
speakerdeck
PRO
29
5.4k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
48
2.9k
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