Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Class.new is all you need
Search
Shia
April 22, 2026
Technology
700
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Class.new is all you need
RubyKaigi 2026 LT
Shia
April 22, 2026
More Decks by Shia
See All by Shia
Good Enough Types: Heuristic Type Inference for Ruby
riseshia
1
4.8k
型を書かないRuby開発への挑戦
riseshia
0
6.1k
ひとつの開発環境
riseshia
0
140
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
410
スパイクアクセス対策としての pitchfork 導入
riseshia
0
1k
NewEngineering 2024 - 繋がっていくサービスを支える開発環境作り
riseshia
0
1.9k
Hotspot on Coverage
riseshia
0
310
差分ベースで効率的にテストを実行してみる
riseshia
1
840
Cookpad internship 2020 summer - web
riseshia
0
7.7k
Other Decks in Technology
See All in Technology
PM領域でのAI Agentの活用
lycorptech_jp
PRO
0
280
推論の観測、できていますか? 〜 Google Cloud Gemini Enterprise Agent Platformで 3つの Gemini モデルを実測して踏んだ、評価の罠 〜
shukob
PRO
0
170
AI時代におけるプロダクト横断勉強会の設計
zozotech
PRO
0
170
作り直せるコードは迅速に 作り直せないDBは慎重に - AI時代のプロダクトエンジニアが「判断の不可逆性」で開発速度を変える話
kinosuke01
0
270
多摩川(.dev)ランニング入門 / Tamagawa.dev#3
fujiwara3
3
400
Bet AI Day 2026丨AIによって本質に戻るシステムリスク管理
layerx
PRO
0
1.3k
設計の世代交代を乗り越える、14年続くAndroidアプリの開発戦略
sansantech
PRO
1
150
Amazon Quick on DesktopがIAM Identity Centerで動かない理由
yukiogawa
0
100
Microsoft 365 Copilot chat -tekoälypalvelun tietosuojaongelmat
hponka
0
540
Multica × 長期記憶:40個のミニプロジェクト管理
eiei114
1
200
Kiro Crewしか勝たん!?
miu_crescent
PRO
0
190
なぜSRE・セキュリティは評価されないのか?守りの組織を事業成長エンジンに変えた実践
cscengineer
PRO
3
2.3k
Featured
See All Featured
New Earth Scene 8
popppiees
3
2.5k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
340
How to Think Like a Performance Engineer
csswizardry
28
2.8k
sira's awesome portfolio website redesign presentation
elsirapls
0
410
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
67
58k
Facilitating Awesome Meetings
lara
57
7.1k
Git: the NoSQL Database
bkeepers
PRO
432
67k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
Bootstrapping a Software Product
garrettdimon
PRO
306
120k
Exploring anti-patterns in Rails
aemeredith
3
490
4 Signs Your Business is Dying
shpigford
187
23k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Transcript
RubyKaigi 2026 LT Shia@STORES Class.new is all you need
SIM SANGYONG (@shia) - STORES Inc. - GitHub: @riseshia -
X: @riseshia Self Introduction 2
SIM SANGYONG (@shia) - STORES Inc. - GitHub: @riseshia -
X: @riseshia - And…Day 3!!! Self Introduction 3
"type-guessr" needed to collect info from project code at startup
and it was slow. So, I profiled and… Background 4
ko1: "Class.new is faster than them" shia: "…!?!?" Background 5
Target: Initialization speed - Data.define, Struct, Class - kwargs, positional
args - 1 ivar, 8 ivars Ruby 4.0.1 / linux / no YJIT So, benchmark it 6
Result 7 1 field 8 fields
- Class.new > Struct.new >> Data.define.new - kwargs are slow
- more ivars, more slower Observation 8
Observation 9 8 fields - Class.new > Struct.new >> Data.define.new
- kwargs are slow - more ivars, more slower Note: Class.new outperforms with YJIT
See perf results 10 "perf record -g --call-graph dwarf" Ruby
4.0.1 / linux / no YJIT / ivar 1 field
See perf results 11
See perf results 12
See perf results 13
See perf results 14
See perf results 15
- Is kwargs initialization optimized? - Create Hash for kwargs
on initialization or not - Is ivar access optimized? - Byte code caching with object shape applied or not - Does the object need to be frozen? Why?? 16
shia: "I found it really is.." ko1: "We optimize what
people use most, so yeah" shia: "That's absolutely true😂" After talk 17
I originally used Data because I vaguely assumed Data/Struct was
lighter than Class. Reality was different at least object initialization. Did you know that? Summary 18
〜Fin〜 19
🤔 20
If "Class" is the fastest, why not re-implement these with
it?? 🤔🤔🤔 How to speed up Struct or Data.define 21
Re-impl Struct with "Class", and benchmark again: (8 fields, YJIT
off/on) How to speed up Struct or Data.define 22
It’s really fast! Let’s submit this patch!!!
Let’s submit this patch!!! 24
Submit this patch…? 25
🫠 26
🚮 27
28 You can check the full benchmark & RubyStruct implementation!
https://github.com/riseshia/class-new-is-all-you-need Class.new might be all you need (if initialization perf matters)