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
38
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
690
実例で学ぶ画像最適化集 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
「Docker Desktop不要の時代」は 来たのか?
ueponx
0
650
AIにシークレットを見せない、WSL2で安全な開発環境
yazm
0
180
触りたくないデータに、どう触るか AI時代のRBACアクセスガバナンス
ivry_presentationmaterials
0
140
実践!Cloud Run ハンズオン!! / Cloud Run handson
y0hgi
2
260
Claude Code本は、どのように執筆チームで書かれたか
oikon48
1
370
パッチ更新でterraform initが落ちた日
grimoh
1
130
宣言型部分更新は何を解決しどこへ向かうのか
shuta13
1
400
使いこなすために知っておきたい Azure SRE Agent アンチパターン
torumakabe
2
500
Claude の新機能を、 出た日に触って社内に届けるまで
rfdnxbro
1
110
Running Kotlin + Quarkus with Lambda
nealle
1
470
TinyGoでオブザーバビリティ?OpenTelemetryはTinyGoで使えるのか / Is OpenTelemetry available in TinyGo environment?
ymotongpoo
2
140
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
320
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1033
470k
WCS-LA-2024
lcolladotor
0
880
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
2.2k
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
270
Unsuck your backbone
ammeep
672
58k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
570
A Modern Web Designer's Workflow
chriscoyier
699
190k
Kristin Tynski - Automating Marketing Tasks With AI
techseoconnect
PRO
0
550
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
600
The Anti-SEO Checklist Checklist. Pubcon Cyber Week
ryanjones
0
270
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.9k
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