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
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
Search
Susisu
August 23, 2025
Technology
2.7k
7
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Go で言うところのアレは TypeScript で言うとコレ / Kyoto.なんか #7
Kyoto.なんか #7
https://kyoto-nanka.connpass.com/event/365370/
Susisu
August 23, 2025
More Decks by Susisu
See All by Susisu
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.6k
君だけのオリジナル async / await を作ろう / TSKaigi 2025
susisu
19
15k
null or undefined
susisu
25
7.9k
Mackerel のフロントエンドフレームワーク移行 序章 / Hatena Engineer Seminar #13
susisu
0
2.3k
スクリーンショット撮影のために Puppeteer を操る / Kyoto.js 16
susisu
0
980
BuckleScript 使ってみた
susisu
0
420
Atom パッケージ開発のすゝめ
susisu
1
2.3k
5分でわかる Curry–Howard 同型対応
susisu
0
1.2k
ジェネレータを有効活用し隊 / Kyoto.js 11 LT
susisu
2
2.3k
Other Decks in Technology
See All in Technology
AIソロプレナー時代に2ヶ月で20人増員した事業創造会社の開発組織の話
miyatakoji
0
600
RAG を使わないという選択肢
tatsutaka
1
190
2026TECHFRESH畢業分享會 - Lightning Talk - E起 See See : 電商推薦讀心術? 數據說了算
line_developers_tw
PRO
0
790
SIer20年! 培ったスキルがスタートアップで輝く時
shucho0103
0
840
攻撃者視点で考えるDetection Engineering
cryptopeg
1
1.2k
データサイエンスを価値につなげるプロジェクト設計 〜 DS一年目が現場で得た気づき 〜
ysd113
1
180
2026.06.13_AI時代に事業会社が「SIer出身エンジニア」を求める理由 / Why Businesses Seek Engineers with a System Integrator Background in the AI Era
jumtech
0
1k
エンジニアリング戦略の作り方 / Crafting Engineering Strategy
iwashi86
20
6.6k
ACE-Step-1.5で見る 音楽生成AIのしくみと“破綻だけ直す”Retake機能の開発【zennfes spring 2026 登壇資料】
personabb
1
130
社内 AI エージェント Synapse と セマンティックレイヤーの育て方
hiroakis
2
1.7k
FinOps × AIエージェントで実現する コストインシデントの自動調査
oasis1994liveforever
0
120
Oracle AI Database@Azure:サービス概要のご紹介
oracle4engineer
PRO
6
1.9k
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.6k
Amusing Abliteration
ianozsvald
1
200
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
The agentic SEO stack - context over prompts
schlessera
0
810
Breaking role norms: Why Content Design is so much more than writing copy - Taylor Woolridge
uxyall
0
320
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Noah Learner - AI + Me: how we built a GSC Bulk Export data pipeline
techseoconnect
PRO
0
200
HDC tutorial
michielstock
2
700
The Cost Of JavaScript in 2023
addyosmani
55
10k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
390
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
290
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
1
180
Transcript
id:susisu / 2025-08-23 Kyoto.ͳΜ͔ #7 GoͰݴ͏ͱ͜ΖͷΞϨ TypeScriptͰݴ͏ͱίϨ
None
None
࠷ۙॻ͍ͨTypeScript
࠷ۙॻ͍ͨTypeScriptʢ̍ʣ • ಠཱͳ worker Λෳىಈͯ͠δϣϒΛॲཧͯ͠Β͏ main workerα workerβ workerγ ⋮
δϣϒΛΤϯΩϡʔ
࠷ۙॻ͍ͨTypeScriptʢ̍ʣ • main ͷऴྃ࣌ʹ worker ॲཧதͷδϣϒ͕ऴΘΓ࣍ୈఀࢭͤ͞Δ main workerα workerβ workerγ
⋮ ܬͷޫ SIGTERM
• API αʔόʔ͔ΒͷετϦʔϜΛӬଓԽͭͭ͠ΫϥΠΞϯτʹฦ͢ app server ࠷ۙॻ͍ͨTypeScriptʢ̎ʣ req handler worker API
server DB client ϦΫΤετ ϦΫΤετ ىಈ
• API αʔόʔ͔ΒͷετϦʔϜΛӬଓԽͭͭ͠ΫϥΠΞϯτʹฦ͢ app server ࠷ۙॻ͍ͨTypeScriptʢ̎ʣ req handler worker API
server DB client Ϩεϙϯε Ϩεϙϯε ӬଓԽ Ϩεϙϯε
• ΫϥΠΞϯτ్͕தͰஅ͞ΕͯӬଓԽͳͲͷॲཧଓ͚Δ app server ࠷ۙॻ͍ͨTypeScriptʢ̎ʣ req handler worker API server
DB client X X ӬଓԽ Ϩεϙϯε
app server req handler worker API server DB client X
X ӬଓԽ Ϩεϙϯε main workerα workerβ workerγ ⋮ ܬͷޫ SIGTERM Go͔ʁ
͍͔ʹGoͰॻ͖ͦ͏ • ಠཱͨ͠ worker → goroutine • தஅγάφϧͷ → context
• worker ؒͷσʔλૹड৴ → channel
TypeScriptͰͲ͏͢Δʁ • ಠཱͨ͠ worker → ? • தஅγάφϧͷ → ?
• worker ؒͷσʔλૹड৴ → ?
goroutine • ܰྔεϨου, ฒߦɾฒྻॲཧ go func() { time.Sleep(time.Second) fmt.Println("Pong") }()
fmt.Println("Ping") // Ping // (1s) // Pong
goroutine → async function • ϚϧνεϨου͕ཉ͍͠ͳΒ Web Workers ͳͲ͕ඞཁ͚ͩͲ (async
function() { await setTimeout(1000); console.log("Pong"); })(); console.log("Ping"); // Ping // (1s) // Pong
context • தஅγάφϧͷ ctx, cancel := context.WithCancel(context.Background()) startWorker(ctx) // ...
cancel()
context → AbortController • DOM Standard Ͱఆٛ͞Ε͍ͯΔ AbortController ͕͑Δ const
ac = new AbortController(); startWorker(ac.signal); // ... ac.abort();
context • ϦΫΤετείʔϓͷͷʹΘΕΔ ctx := context.WithValue(context.Background(), "requestId", "c0ffee") handler(ctx) //
handler: ctx.Value("requestId") // = "c0ffee"
context → ? • ୯ʹΦϒδΣΫτΛҾͰ͢ͷ͕جຊ͚ͩͲ... const ctx = { requestId:
"c0ffee" }; handler(ctx); // handler: ctx.requestId; // = "c0ffee"
context → AsyncLocalStorage • ҾΛ͢ͷ͕͍࣌͠ AsyncLocalStorage (ඇඪ४) ͕ศར͔ const storage
= new AsyncLocalStorage<{ requestId: string }>(); const ctx = { requestId: "c0ffee" }; storage.run(ctx, () => { handler(); }); // handler: storage.getStore()?.requestId; // = "c0ffee"
channel • goroutine ؒͷσʔλͷૹड৴ c := make(chan int) go func()
{ for n := 0; n < 10; n++ { c <- n } close(c) }() for n := range c { fmt.Println(n) } // 0, 1, 2, ..., 9
channel → Streams • Streams API ͰࣅͨΑ͏ͳ͜ͱ͕Ͱ͖·͢ const { readable,
writable } = new TransformStream<number, number>(); (async function() { const writer = writable.getWriter(); for (let n = 0; n < 10; n++) { await writer.write(n); } await writer.close(); })(); for await (const n of readable) { console.log(n); } // 0, 1, 2, ..., 9
channel • ͪͳΈʹऴྃΛ͚ͭͩͳΒ c := make(chan struct{}) go func() {
// ... close(c) }() // ... <-c
channel → await • await ͰΑ͍Ͱ͢Ͷ const promise = (async
function() { // ... })(); // ... await promise;
·ͱΊʢ̍ʣ • Go Ͱݴ͏ͱ͜ΖͷΞϨ TypeScript Ͱݴ͏ͱίϨ • goroutine → async
function • context → AbortController, AsyncLocalStorage • channel → Streams ͳͲ
·ͱΊʢ̎ʣ • TypeScript Λॻ͍͍ͯͯৗʹ TypeScript Ͱߟ͍͑ͯΔΘ͚Ͱͳ͍ • ࣮ࡍߟ͍͑͢ݴޠϝϯλϧϞσϧͬͯߟ͍͑ͯΔ • ࠓճͨ·ͨ·
Go ͬΆ͔ͬͨ • ৭ʑ͍ͬͯΔͱศར