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
740
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
240
UnixTime is Simple
mattak
0
160
おっさんが停滞しないために
mattak
32
18k
tech invest
mattak
1
300
Nodux - node base redux framework
mattak
0
1.4k
what_is_technical_investment
mattak
0
120
unitypackage distribution
mattak
0
760
Unity energy usage
mattak
0
850
Unidux 0.3.1
mattak
1
360
Other Decks in Programming
See All in Programming
『ドメイン駆動設計をはじめよう』のモデリングアプローチ
masuda220
PRO
8
540
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
Snowflake x dbtで作るセキュアでアジャイルなデータ基盤
tsoshiro
2
520
Contemporary Test Cases
maaretp
0
140
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
watsonx.ai Dojo #4 生成AIを使ったアプリ開発、応用編
oniak3ibm
PRO
1
100
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
광고 소재 심사 과정에 AI를 도입하여 광고 서비스 생산성 향상시키기
kakao
PRO
0
170
距離関数を極める! / SESSIONS 2024
gam0022
0
280
Better Code Design in PHP
afilina
PRO
0
120
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
Featured
See All Featured
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
Fireside Chat
paigeccino
34
3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Product Roadmaps are Hard
iamctodd
PRO
49
11k
Keith and Marios Guide to Fast Websites
keithpitt
409
22k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.1k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
6.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
232
140k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
6
410
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