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
プロダクト志向ってなんなんだろうね
righttouch
PRO
0
190
10 Costly Database Performance Mistakes (And How To Fix Them)
andyatkinson
0
340
Rubyでやりたい駆動開発 / Ruby driven development
chobishiba
1
730
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
170
明示と暗黙 ー PHPとGoの インターフェイスの違いを知る
shimabox
2
510
AIプログラマーDevinは PHPerの夢を見るか?
shinyasaita
1
220
地方に住むエンジニアの残酷な現実とキャリア論
ichimichi
5
1.5k
git worktree × Claude Code × MCP ~生成AI時代の並列開発フロー~
hisuzuya
1
570
Deep Dive into ~/.claude/projects
hiragram
14
2.6k
AI時代のソフトウェア開発を考える(2025/07版) / Agentic Software Engineering Findy 2025-07 Edition
twada
PRO
87
29k
「テストは愚直&&網羅的に書くほどよい」という誤解 / Test Smarter, Not Harder
munetoshi
0
170
イベントストーミング図からコードへの変換手順 / Procedure for Converting Event Storming Diagrams to Code
nrslib
2
820
Featured
See All Featured
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
Facilitating Awesome Meetings
lara
54
6.4k
The Cost Of JavaScript in 2023
addyosmani
51
8.5k
How GitHub (no longer) Works
holman
314
140k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
8
820
4 Signs Your Business is Dying
shpigford
184
22k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
45
7.5k
Why Our Code Smells
bkeepers
PRO
336
57k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
233
17k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.4k
Designing for humans not robots
tammielis
253
25k
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