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
390
1
Share
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
430
型を書かないRuby開発への挑戦
riseshia
0
1.7k
ひとつの開発環境
riseshia
0
82
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
340
スパイクアクセス対策としての pitchfork 導入
riseshia
0
890
NewEngineering 2024 - 繋がっていくサービスを支える開発環境作り
riseshia
0
1.7k
Hotspot on Coverage
riseshia
0
290
差分ベースで効率的にテストを実行してみる
riseshia
1
800
Cookpad internship 2020 summer - web
riseshia
0
7.7k
Other Decks in Technology
See All in Technology
Purview 勉強会報告 Microsoft Purview 入門しようとしてみた
masakichixo
1
110
freeeで運用しているAIQAについて
qatonchan
0
420
AI対話分析の夢と、汚いデータの現実 Looker / Dataplex / Dataform で実現する品質ファーストな基盤設計
waiwai2111
0
260
オライリーイベント登壇資料「鉄リサイクル・産廃業界におけるAI技術実応用のカタチ」
takarasawa_
0
350
Agent Skillsで実現する記憶領域の運用とその後
yamadashy
2
1.5k
サンプリングは「作る」のか「使う」のか? 分散トレースのコストと運用を両立する実践的戦略 / Why you need the tail sampling and why you don't want it
ymotongpoo
3
140
ハーネスエンジニアリング入門
knishioka
0
140
多角的な視点から見たAGI
terisuke
0
130
生成AIはソフトウェア開発の革命か、ソフトウェア工学の宿題再提出なのか -ソフトウェア品質特性の追加提案-
kyonmm
PRO
2
870
小さいVue.jsを30分で作る
hal_spidernight
0
150
The 7 pitfalls of AI
ufried
0
200
Sociotechnical Architecture Reviews: Understanding Teams, not just Artefacts
ewolff
1
150
Featured
See All Featured
Agile Actions for Facilitating Distributed Teams - ADO2019
mkilby
0
180
Dominate Local Search Results - an insider guide to GBP, reviews, and Local SEO
greggifford
PRO
0
160
Navigating Weather and Climate Data
rabernat
0
180
The Cult of Friendly URLs
andyhume
79
6.9k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
55k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.3k
The Power of CSS Pseudo Elements
geoffreycrofte
82
6.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.5k
Automating Front-end Workflow
addyosmani
1370
200k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.1k
Being A Developer After 40
akosma
91
590k
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)