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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Shia
April 22, 2026
Technology
540
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
4.4k
型を書かないRuby開発への挑戦
riseshia
0
5.7k
ひとつの開発環境
riseshia
0
92
Conquering Massive Traffic Spikes in Ruby Applications with Pitchfork
riseshia
0
360
スパイクアクセス対策としての pitchfork 導入
riseshia
0
930
NewEngineering 2024 - 繋がっていくサービスを支える開発環境作り
riseshia
0
1.7k
Hotspot on Coverage
riseshia
0
290
差分ベースで効率的にテストを実行してみる
riseshia
1
810
Cookpad internship 2020 summer - web
riseshia
0
7.7k
Other Decks in Technology
See All in Technology
MIERUNE JCT 発表資料「宇宙から伊能忠敬ごっこ」
syuchimu
0
110
TROCCOで始めるクラウドコストを民主化するためのFinOps
tk3fftk
3
560
APIテストとは?
nagix
0
170
ポスター発表&デモと総括 / Poster Presentations & Demonstrations and Summary
ks91
PRO
0
190
Javaコミュニティをもっと楽しむための9箇条
takasyou
0
1.2k
BigQuery の Cross-cloud Lakehouse への歩み
phaya72
2
540
エンジニアは生成AIと どのように向き合うべきか? ことばの意味という観点から
verypluming
3
340
Platform Engineering as a Product: Criteria for Improvement and Multi-Tenant Design
kumorn5s
0
480
oracle-to-databricks-migration-with-llm-and-dbt
casek
1
420
関西に縁あるMicrosoft MVPsが語るCopilotの未来
kasada
0
1k
さきさん文庫の書籍ができるまで
sakiengineer
0
330
オンコールの負荷軽減のためのBits Assistant 活用方法 / How to Use Bits Assistant to Reduce the Workload on On-Call Staff
sms_tech
1
380
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
Abbi's Birthday
coloredviolet
2
7.9k
Designing Experiences People Love
moore
143
24k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
240
Unlocking the hidden potential of vector embeddings in international SEO
frankvandijk
0
830
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
10k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
150
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Designing for Timeless Needs
cassininazir
1
250
Code Reviewing Like a Champion
maltzj
528
40k
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)