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
Diff algorithm abstraction in Go
Search
Tatsuhiko Kubo
September 27, 2026
Technology
44
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Diff algorithm abstraction in Go
Tatsuhiko Kubo
September 27, 2026
More Decks by Tatsuhiko Kubo
See All by Tatsuhiko Kubo
Mackerel in さくらのクラウド
cubicdaiya
1
1.1k
Handling a tremendous amount of images with Fastly / Yamagoya Traverse 2020
cubicdaiya
2
1.6k
System Integration with Fastly
cubicdaiya
0
700
実例で学ぶ画像最適化集 with ImageFlux / ImageFlux meetup#2
cubicdaiya
4
20k
Software Engineer, Infrastructure
cubicdaiya
4
3.3k
High Performance Count Up!
cubicdaiya
0
440
ImageFluxを利用した画像配信の最適化 / ImageFlux meetup 201801
cubicdaiya
0
3.2k
Building high performance push notification server in Go
cubicdaiya
5
3.5k
メルカリのデータ分析基盤 / mercari data analysis infrastructure
cubicdaiya
11
12k
Other Decks in Technology
See All in Technology
reInvent2026stby LT00 "Change your life!"
shinichirokawano
1
570
複雑な業務システムを高速でつくるため、チーム全員をつくれる人へ
ayakurabuchi
0
130
バックオフィスに染み出すTypeScript ── clasp で安全に仕組みを作る
nealle
1
180
基本から分かる!AWSセキュリティ運用の考え方と任せ方
cmusudakeisuke
1
400
続・ソフトウェアアーキテクトのための意思決定術: Decision Readiness, Revisited — When AI Changes the Economics of Software Architecture
snoozer05
PRO
5
1.3k
Flutter Widget Previewerで始めるUIプレビューとVRTの自動化
sakusaku3939
0
210
AIエージェントの監視、思考を見るか行動を見るか / Monitoring AI Agents: Thoughts or Actions
yusukeshimizu
1
120
公共システムAdventCalendar2026
toru_kubota
0
160
コードレビューをなくして見えたもの
henteko
0
130
[General] 개발자로 해외 기업에서 일하기
skydoves
1
290
kintoneで在庫管理システムを作るときの要件定義・設計ポイント
kai0707
0
230
Copilot Coworkで「みのるん式」やってみた
minorun365
PRO
2
1.5k
Featured
See All Featured
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
52
6.2k
Stop Working from a Prison Cell
hatefulcrawdad
274
21k
KATA
mclloyd
PRO
35
16k
It's Worth the Effort
3n
188
29k
VelocityConf: Rendering Performance Case Studies
addyosmani
331
25k
Music & Morning Musume
bryan
48
7.5k
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
480
Navigating Team Friction
lara
192
16k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
620
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
70
68k
Self-Hosted WebAssembly Runtime for Runtime-Neutral Checkpoint/Restore in Edge–Cloud Continuum
chikuwait
0
920
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
510
Transcript
Diff algorithm abstraction in Go さくらインターネット株式会社 SRE本部技術支援室 久保達彦
Me • 久保達彦(くぼたつひこ) • @cubicdaiya (X, GitHub) • さくらインターネット株式会社 SRE本部技術支援室
• ピクシブ、メルカリ等を経て2023年から現職 • 「nginx実践入門」書きました(共著) • https://gihyo.jp/book/2016/978-4-7741-7866-0 • 2016年1月16日発売なので、もう10年前
Diff algorithm abstraction in Go
Diffのアルゴリズム解説と実装 by Me • Software Design2009年6月号に記載した記事 • di の動作原理を知る〜どのようにして差分を導き出すのか •
https://gihyo.jp/dev/column/01/prog/2011/di ̲sd200906 • (多分)2008年頃にC++(のテンプレート)で実装したdi ライブラリ:dtl • https://github.com/cubicdaiya/dtl • Go(のGenerics)で実装したdi ライブラリ:gonp ff ff ff ff • https://github.com/cubicdaiya/gonp
今日の発表時間は10分 • 差分を計算するというのは次の3つを求めることと同義 • Edit/Levenshtein Distance(編集距離、レーベンシュタイン距離) • Longest Common Subsequence(LCS、最長共通部分列)
• Shortest Edit Script(SES) • 続きは前のページにあるリンクから
文字列間のdiffを取る by gonp ff https://github.com/cubicdaiya/gonp/blob/master/examples/strdi .go
時は2010年代後半 • GoにはまだGenericsがなかった • Genericsが導入されたのは2022年にリリースされたGo1.18 • 当時のGoにはGenericsが要る/要らない?論争が各所で観測されていた • ※個人の感想です •
私は要る派だった(ホントだよ) • Genericsがないとデータ構造とアルゴリズムを抽象化するのが困難だった • アルゴリズムを抽象化できないとデータ型毎に実装が必要でスケールしない(めんどい) fl • interface{}やre ectionではさすがに無理がある
diffアルゴリズムの抽象化 in dtl(C++版)
diffアルゴリズムの抽象化 in dtl(C++版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
diffアルゴリズムの抽象化 in gonp(Go版)
データ構造/アルゴリズムを抽象化するためのGenerics • Genericsの真価はデータ構造やアルゴリズムの抽象化において発揮される • 一般的なWebアプリケーションやAPIの開発だとあまり使う機会はない • 差分アルゴリズム1つを取っても抽象化することのメリットは大きい • 文字列間、テキストファイル間等 •
差分にも種類がある(e.g. Uni ed Format Di erence) • 2010年代にgonpを実装した頃は面倒なので文字列しかサポートしていなかった • Genericsが導入されたその月(2022/03)に実装しました。簡単だね。 ff fi • https://zenn.dev/cubicdaiya/articles/0fa9c15e9cd295
おまけ https://github.com/cubicdaiya/gonp
おまけ https://github.com/cubicdaiya/gonp
おまけ https://github.com/cubicdaiya/gonp
いつの間にか結構使われていた • sqlcでも使われているそうです(本スライド作成時:2026/09/14) • https://github.com/sqlc-dev/sqlc • sqlc di というサブコマンドがある •
https://github.com/sqlc-dev/sqlc/pull/1963 • https://docs.sqlc.dev/en/latest/howto/ci-cd.html • 最近だと上司が使ってた ff ff • https://github.com/monitoring-forge/check-di /pull/11
まとめ • Genericsの真価はアルゴリズムの抽象化において発揮される • Di 実装は結構需要がある • 差分をテキストではなく、データ構造として扱えるのはなんだかんだ で便利 •
dtl(C++実装) • https://github.com/cubicdaiya/dtl • gonp(Go実装) ff • https://github.com/cubicdaiya/gonp