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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
はてなのサービス基盤を支える Kubernetes《足腰》
masayoshimaezawa
0
210
クレデンシャル流出 ― 攻撃 3 時間 vs 復旧 10 時間。この非対称性にどう備えるか
kazzpapa3
3
620
本当の”仕事”を手放せる未来が見えた
mu7889yoon
0
200
【FinOps】データドリブンな意思決定を目指して
z63d
2
490
Agile and AI Redmine Japan 2026
hiranabe
4
500
CVE-2026-20833_脆弱性対応とAES 化について
jukishiya
0
200
iOS アプリの「これって不具合ですか?」を AI に調べてもらう
miichan
0
150
AI時代における最適なQA組織の作り方
ymty
3
170
サイバーエージェントにおけるAI推進戦略と変革への取り組み
shotatsuge
0
610
從開發到部署全都交給 AI:實作 AI 驅動的自動化流程
appleboy
0
180
Docker Desktop不要の時代が来る? WSL標準の「wslc」で Linuxコンテナを動かしてみた.
ueponx
0
180
Comment regagner la souveraineté de vos données tout en étant payé grâce à Nostr !
rlifchitz
0
220
Featured
See All Featured
jQuery: Nuts, Bolts and Bling
dougneiner
66
8.5k
From π to Pie charts
rasagy
0
220
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
0
540
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.3k
Making the Leap to Tech Lead
cromwellryan
135
9.9k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
190
Designing Experiences People Love
moore
143
24k
Measuring Dark Social's Impact On Conversion and Attribution
stephenakadiri
2
230
[SF Ruby Conf 2025] Rails X
palkan
2
1.1k
Bash Introduction
62gerente
615
220k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
62
44k
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 ͬΆ͔ͬͨ • ৭ʑ͍ͬͯΔͱศར