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
Persisting Massive Data with Rails ~Designing for 60 billion rows, and fighting the bottlenecks~ Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
0
530
無理せず続ける、子育てエンジニアの学び
codmoninc
PRO
0
730
FOSS4Gを活用した自治体業務DXの試み
470715
0
150
Railsで挑む大量データ永続化 〜600億件を永続化するための設計とボトルネックとの戦い〜
occhi
1
280
「事実」を「計測」して、「解釈」する 〜AWS Lambdaのメモリ最適解の見つけ方〜
maimyyym
0
150
SREでアラート疲れを 解決しよう!
kairim0
1
230
FactoryBotアンチパターン / factory_bot anti-patterns
toshimaru
0
160
[JAWS-UG彩の国埼玉#12]そろそろ準備する?re:Invent2026をやさしく解説 / reinvent2026-sainokuni
sh_fk2
1
190
AIカンパニーへの転換を支えた、エンジニアの仕事の再定義
kworkdev
PRO
2
710
実践! SRE × AI - ABEMA における AIOps -
tetsuya28
8
3k
NDIでApple Vision Proにリアルタイム映像送信
jyouryuusui
0
110
AIがコードを書く時代に、エンジニアは何で自分の価値を証明するのか / In an era where AI writes code how do engineers prove their value
carta_engineering
3
950
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.7k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
320
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Automating Front-end Workflow
addyosmani
1369
210k
Producing Creativity
orderedlist
PRO
348
41k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
1k
WENDY [Excerpt]
tessaabrams
14
40k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
700
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Building the Perfect Custom Keyboard
takai
2
900
The Language of Interfaces
destraynor
162
27k
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