Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Kotlin/JS の仕組み / How KotlinJS works
Search
Yuku Kotani
August 24, 2019
Technology
3.5k
5
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Kotlin/JS の仕組み / How KotlinJS works
Kotlin Fest 2019の発表資料
Yuku Kotani
August 24, 2019
More Decks by Yuku Kotani
See All by Yuku Kotani
Webとヘルスデータ
yukukotani
1
820
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
4
5.5k
一億総業務改善を支える社内AIエージェント基盤の要諦
yukukotani
9
3.7k
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
6
3k
Scale out your Claude Code ~自社専用Agentで10xする開発プロセス~
yukukotani
11
6k
AI Coding Agent Enablement in TypeScript
yukukotani
21
21k
AI Coding Agent Enablement - エージェントを自走させよう
yukukotani
14
8.7k
Expoによるアプリ開発の現在地とReact Server Componentsが切り開く未来
yukukotani
3
970
React 19でお手軽にCSS-in-JSを自作する
yukukotani
6
1.1k
Other Decks in Technology
See All in Technology
VS Code × GitHub Copilot での Fabric 開発
ryomaru0825
1
270
AIは爆速なのに、私が詰まっていた話 ― 音声入力と鳴くマスコットでボトルネックを削る
yama3133
0
510
AI臭い文章とは何なのか
nasuvitz
38
79k
Claude起点の仕様駆動開発
tanakaseiya
0
350
DAMOS - The Smart Cruise Control for RAM
ennael
PRO
1
120
The seven pitfalls of AI (revised version)
ufried
0
240
freeeらしさをAIとともに作る / Creating the freee Experience with AI
ymrl
0
180
FinTech 1-2 : Overview of FinTech
ks91
PRO
0
140
ビジネスを止めない技術的負債の返済のための戦略とその手法 - 技術的負債と向き合う / Complexity and Simplicity
soudai
PRO
3
530
IoTデバイスを繋げるプロトコルMatterをAndroidで使用する方法
harutiro
0
110
あなたの知らないAmazon VPC Route Server/Amazon VPC Route Server you don't know about
masakiokuda
2
220
ミイダス株式会社 テックチームのご紹介 / MIIDAS Tech Team
miidas
0
120
Featured
See All Featured
How to Ace a Technical Interview
jacobian
280
24k
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
290
Heart Work Chapter 1 - Part 1
lfama
PRO
10
36k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
3.2k
Product Roadmaps are Hard
iamctodd
55
13k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
520
A designer walks into a library…
pauljervisheath
211
25k
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
900
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
31k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Transcript
Kotlin/JS の仕組み Kotlin Fest 2019
自己紹介 - 名前: 小谷 優空 (Yuku Kotani) - GitHub: @Monchi
- Twitter: @MonchiFC - 所属: Ubie, Everforth, 筑波大学情報科学類 - Kontributor 2
コンパイルの流れ
謎のコンパイラ コンパイルの流れ 4 CLI kotlin-gradle-plugin JVM JavaScript Native(LLVM) 出力
コンパイルの流れ 5 CLI kotlin-gradle-plugin JVM JavaScript Native(LLVM) AST (PSI) Kotlin
コード コンパイラ 出力 IR (中間表現)
コンパイルの流れ 6 CLI kotlin-gradle-plugin JVM JavaScript Native(LLVM) AST (PSI) Kotlin
コード コンパイラ 出力 参照 コンパイル先に関わらず Kotlinコードとして 参照、操作できる! IR (中間表現)
コンパイルの流れ 7 CLI kotlin-gradle-plugin JVM JavaScript Native(LLVM) AST (PSI) Kotlin
コード コンパイラ 出力 IR (中間表現)
Kotlin/JS変換の工夫
Dead Code Elimination - Tree Shakingとも言う - 使われていない関数やプロパティ、クラスを削除 - KotlinのIRも参照する
- JSにしてからwebpackとか使うより精度がいい 9
結局バンドルサイズどうなの?
Dead Code Elimination - 単純なTodoMVCアプリケーションをDCE 1922KB -> 416KB - minifyすると更に
198KB に - gzipすると更に 45KB に - webpackのTree Shakingも重ねがけでもっと減らせそう 11
型変換 - KotlinからJavaScriptに型変換 String -> string Int -> number Any
-> {} クラス -> prototypeでよしなに 12
型変換 - 型付き配列 - 型に応じて [], Int8Array, Int16Array... に変換 -
Long(64bit整数) - JavaScriptは53bit整数までしか扱えない - 内部的にエミュレートするKotlin.Longクラスに変換 13
モジュール 14 - JavaScriptには様々なモジュール管理方法がある - Kotlin/JSもそれに合わせて色々吐ける - plain: そのままブラウザで動く -
commonjs, amd: webpackとかでバンドルする - umd: 上2つのハイブリッド
moduleKind = plain の場合
moduleKind = plain の場合 グローバル変数として定義
moduleKind = plain の場合 - モジュールシステムを使わない - ブラウザでそのまま動く - 依存順を意識してロードする必要がある
moduleKind = commonjs の場合
moduleKind = commonjs の場合 require()でロード
moduleKind = commonjs の場合 - Node.jsのモジュールシステム - Webpackなどでバンドルする必要がある - 最適化の余地がある
- ライブラリとして他から読み込める(JSからも!)
Kotlin/JSすげー! もっと知りてー!
Deep Dive into Kotlin/JS 22
Deep Dive into Kotlin/JS 23 激アツリポジトリ
Deep Dive into Kotlin/JS 24 https://github.com/JetBrains/kotlin/tree /master/compiler/ir/backend.js 信じられるのはソースコードだけ
25 ありがとうございました Kotlinかわいい!