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
22
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
430
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
HolmesGPTで始めるSREエージェント入門!プラットフォームの障害調査はAIにお任せ 〜
sanghyuk
0
160
「大丈夫そう?」をObservabilityで確かめる
mrmtsu
0
170
What the customer really needed
kawaguti
PRO
3
230
AIエージェントを安全で速い現場監督にする:Jev・Obsidian・メタハーネス
x5gtrn
PRO
0
120
Coil3を内部実装から読み解く~キャッシュ戦略とAVIF画像の描画〜/nikkei-tech-talk50
nikkei_engineer_recruiting
0
100
EventBridge に「合流」はない ― サーバーレスのワークフローを育てるということ / No Join in EventBridge
yusukeshimizu
2
560
音声コミュニティを守るAI監視基盤_ 90%以上の入力削減を支えたServerless設計と運用判断
shuheioka123
0
110
2026-09-18 gotanda.sre Terraformで複数環境作ったり、複数Stateに分割したりそれとTerragrunt / Terraform multi envs and multi states
masasuzu
4
740
[Kiro Meetup #7] Kiro Crew Dive Deep
konippi
0
350
技術的負債から考える、AI時代のエンジニアリング投資 — ビズリーチの技術的負債と向き合った経験から、変更し続けられるソフトウェアを考える/ technical-debt-con2026
visional_engineering_and_design
4
3.8k
Antigravity SDK for the Java Developer
glaforge
0
210
SREへの勘違いに気づいた後の話
tomodakengo
0
160
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Evolving SEO for Evolving Search Engines
ryanjones
0
300
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
440
Raft: Consensus for Rubyists
vanstee
142
7.7k
Speed Design
sergeychernyshev
33
2.1k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
530
Design in an AI World
tapps
1
330
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
680
How STYLIGHT went responsive
nonsquared
100
6.3k
We Are The Robots
honzajavorek
0
380
WENDY [Excerpt]
tessaabrams
14
39k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
310
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