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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Yuku Kotani
August 24, 2019
Technology
3.6k
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
930
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
4
5.6k
一億総業務改善を支える社内AIエージェント基盤の要諦
yukukotani
9
3.7k
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
6
3.1k
Scale out your Claude Code ~自社専用Agentで10xする開発プロセス~
yukukotani
11
6.1k
AI Coding Agent Enablement in TypeScript
yukukotani
21
21k
AI Coding Agent Enablement - エージェントを自走させよう
yukukotani
14
8.7k
Expoによるアプリ開発の現在地とReact Server Componentsが切り開く未来
yukukotani
3
1k
React 19でお手軽にCSS-in-JSを自作する
yukukotani
6
1.1k
Other Decks in Technology
See All in Technology
ドメインエキスパートは いかにして AI を使って プロダクト開発をするか
tatsuyashiraishi
1
190
背中から、背中へ ー 社外コミュニティで学んだ「雑に背中を押す」という恩送り ー / easygoing encouragement and pay forward to community
naitosatoshi
0
320
トークン化預金DCJPYの取り組みと活用ユースケース
finengine
0
250
クラウドサインを止めずに Nuxt へ 次の10年のために先に決めたこと
bengo4com
1
160
Devin プロモコードの受け取りと適用(2026.10.27)
kinopeee
0
510
Metadata - Section 2: Simple Metadata & Meta Tags
mohab1
0
140
局所最適は悪ではない。壊れているのは指標です。量と質を同時に見る先行指標の設計
recruitengineers
PRO
2
1.2k
(swiftc) NonCopyableとライフタイム修飾子
teamhimeh
0
130
Codex を使った障害対応机上演習の実際
orgachem
PRO
0
360
バフェットコード開発チームの心得(v1.1)
shoe116
0
110
顧客価値を追いかけたら、プライシングにたどり着いた
sansantech
PRO
2
1k
AWS DevOps Agentはどこまで任せられるか 〜機能の現在地と、機能拡張の実践〜
nyankotaro
0
250
Featured
See All Featured
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
The SEO Collaboration Effect
kristinabergwall1
1
600
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
530
4 Signs Your Business is Dying
shpigford
187
23k
Automating Front-end Workflow
addyosmani
1370
210k
How GitHub (no longer) Works
holman
316
150k
BBQ
matthewcrist
90
10k
Discover your Explorer Soul
emna__ayadi
2
1.3k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
280
Why Your Marketing Sucks and What You Can Do About It - Sophie Logan
marketingsoph
0
440
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
580
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.6k
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かわいい!