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
50
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
0
140
型を書かないRuby開発への挑戦
riseshia
0
1.7k
ひとつの開発環境
riseshia
0
79
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
320
スパイクアクセス対策としての pitchfork 導入
riseshia
0
870
NewEngineering 2024 - 繋がっていくサービスを支える開発環境作り
riseshia
0
1.7k
Hotspot on Coverage
riseshia
0
280
差分ベースで効率的にテストを実行してみる
riseshia
1
790
Cookpad internship 2020 summer - web
riseshia
0
7.7k
Other Decks in Technology
See All in Technology
Data Hubグループ 紹介資料
sansan33
PRO
0
2.9k
Digitization部 紹介資料
sansan33
PRO
1
7.3k
20年前の「OSS革命」に学ぶ AI時代の生存戦略
samakada
0
380
AgentCore×VPCでの設計パターンn選と勘所
har1101
3
270
All About Sansan – for New Global Engineers
sansan33
PRO
1
1.4k
みんなで作るAWS Tips 100連発 (FinOps編)
schwrzktz
1
290
Bill One 開発エンジニア 紹介資料
sansan33
PRO
6
18k
Oracle AI Database@AWS:サービス概要のご紹介
oracle4engineer
PRO
4
2.3k
エージェントスキルを作って自分のインプットに役立てよう
tsubakimoto_s
0
140
Code Interpreter で、AIに安全に コードを書かせる。
yokomachi
0
7.1k
JEDAI in Osaka 2026イントロ
taka_aki
0
320
自分のハンドルは自分で握れ! ― 自分のケイパビリティを増やし、メンバーのケイパビリティ獲得を支援する ― / Take the wheel yourself
takaking22
1
880
Featured
See All Featured
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
Writing Fast Ruby
sferik
630
63k
Designing Experiences People Love
moore
143
24k
The Cult of Friendly URLs
andyhume
79
6.8k
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
730
Digital Projects Gone Horribly Wrong (And the UX Pros Who Still Save the Day) - Dean Schuster
uxyall
0
1.1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
380
Being A Developer After 40
akosma
91
590k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2k
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)