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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Tatsuhiko Kubo
September 27, 2026
Technology
18
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
開発投資の期待値を上げるプロダクトロードマップづくり ~プロダクトエンジニアが越境して事業を伸ばす~
kekekenta
1
250
AI coding 整合正規方法
philipz
0
550
Azure Serverless 2026:Production-ready な AI エージェント基盤 / Azure Serverless 2026: Production-Ready AI Agent Platform
miyake
2
600
AIに書かせて、プラットフォームで縛る ― EKSプラットフォームで実践した責任境界と権限設計
elmodev09
0
500
Claude Codeを「使うほど育つ」AI秘書にするノウハウ
minorun365
PRO
33
32k
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
16
120k
品質と信頼性を地続きにする
grimoh
2
1k
.NET WebAssemblyで実現するクライアントサイドAI推論:NuGetからViteまで、2つのエコシステムを繋ぐビルド戦略
yamachu
1
830
AgentCore Runtime上にAgentic Coding基盤を構築・展開する際の設計ポイントと限界点 / Design considerations and limitations when building an agentic coding platform on AgentCore Runtime
har1101
6
760
手を動かして実感する、Kiro が変える開発体験
inariku
0
320
人にやさしく、AIにやさしく、書き手を選ばないIaCのガードレール再考 / Rethinking IaC Guardrails for Humans and AI Alike
kohbis
5
1.1k
人間はどの意思決定を手放せるのか
kawasima
16
8.3k
Featured
See All Featured
The Spectacular Lies of Maps
axbom
PRO
1
1k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.5k
A Soul's Torment
seathinner
8
3.6k
Faster Mobile Websites
deanohume
310
32k
How to Ace a Technical Interview
jacobian
281
24k
Test your architecture with Archunit
thirion
2
2.4k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.6k
Building Experiences: Design Systems, User Experience, and Full Site Editing
marktimemedia
1
610
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
68
58k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
250
Learning to Love Humans: Emotional Interface Design
aarron
275
41k
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