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.8k
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.8k
君だけのオリジナル async / await を作ろう / TSKaigi 2025
susisu
20
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
Docker Desktop不要の時代が来る? WSL標準の「wslc」で Linuxコンテナを動かしてみた.
ueponx
0
190
「ビジネスがわかるエンジニア」とは何か?
ryooob
0
390
「勝手に広まる」人気 AI エージェントを爆速で作ろう!(AWS Summit Japan 2026講演資料)
minorun365
PRO
10
2.6k
アラート調査向けAIエージェントの本番導入とその後/AI Agents for Alert Investigation: Production Deployment and After
taddy_919
1
260
脱SaaS!FDEを支えるプロビジョニングと分離設計
knih
0
310
Oracle Cloud Infrastructure:2026年6月度サービス・アップデート
oracle4engineer
PRO
1
380
Multi-Agent並列開発を 安全に回すための技術 / Technology for Safely Multi-Agent Parallel Development
tooppoo
0
220
AWS Summit Japan 2026の振り返りと2027へ向けて / AWS Summit Japan 2026 Recap and Prospects for 2027
kaminashi
1
100
Hatena Engineer Seminar 37 jj1uzh
jj1uzh
0
190
GitHub Copilot運用のリアル ~AI Credit時代にどう向き合うか~
takafumisu2uk1
0
510
飲食店もAIで。レジ締めやハンディシステムをつくってる話 / Using AI for restaurant management
vtryo
0
210
データレイクの「見えない問題」を可視化する
sansantech
PRO
1
230
Featured
See All Featured
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.5k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
Git: the NoSQL Database
bkeepers
PRO
432
67k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
30 Presentation Tips
portentint
PRO
1
330
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.5k
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
200
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
210
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.2k
The Spectacular Lies of Maps
axbom
PRO
1
830
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 ͬΆ͔ͬͨ • ৭ʑ͍ͬͯΔͱศར