Implementing Embedded TypedData Objects | Rails at Scale

06-Jun-2025 55
Internally, CRuby’s objects are strongly typed, with various types such as Array, Hash, Regexp, and Object. There is also a type called TypedData which is a data type used internally and by native gems to store a native pointer to an arbitrary piece of data. Some types in Ruby that are TypedData objects include Time, Mutex, and Enumerator. Native extensions like Nokogiri, pg, mysql2, and liquid-c also use TypedData objects extensively. Jean Boussier and I implemented TypedData objects on Variable Width Allocation in Ruby 3.3, which improves performance and memory usage. In this blog post, we will explore what TypedData objects are, how the memory layout changes with embedded TypedData objects, and our progress with implementing types on TypedData objects.
Use coupon code:

RUBYONRAILS

to get 30% discount on our bundle!
Prepare for your next tech interview with our comprehensive collection of programming interview guides. Covering JavaScript, Ruby on Rails, React, and Python, these highly-rated books offer thousands of essential questions and answers to boost your interview success. Buy our 'Ultimate Job Interview Preparation eBook Bundle' featuring 2200+ questions across multiple languages. Ultimate Job Interview Preparation eBook Bundle