Talks
Speakers
Events
Topics
Sign in
Home
Talks
Speakers
Events
Topics
Leaderboard
Use
Analytics
Sign in
Suggest modification to this talk
Title
Description
RubyConf 2016 - Building a Better OpenStruct by Ariel Caplan OpenStruct, part of Ruby's standard library, is prized for its beautiful API. It provides dynamic data objects with automatically generated getters and setters. Unfortunately, OpenStruct also carries a hefty performance penalty. Luckily, Rubyists have recently improved OpenStruct performance and provided some alternatives. We'll study their approaches, learning to take advantage of the tools in our ecosystem while advancing the state our community. Sometimes, we can have our cake and eat it too. But it takes creativity, hard work, and willingness to question why things are the way they are.
Date
Summarized using AI?
If this talk's summary was generated by AI, please check this box. A "Summarized using AI" badge will be displayed in the summary tab to indicate that the summary was generated using AI.
Show "Summarized using AI" badge on summary page
Summary
Markdown supported
The video "Building a Better OpenStruct" presented by Ariel Caplan at RubyConf 2016 explores the enhancements made to Ruby's OpenStruct, a standard library tool known for its dynamic data handling capabilities but criticized for its subpar performance. Caplan starts by introducing OpenStruct as reminiscent of JavaScript objects and presents its functionalities, including dynamic property creation and access through dot and bracket notation. Key points discussed include: - **Use Cases for OpenStruct**: Caplan identifies three prominent uses: - **Consuming APIs**: Using OpenStruct to simplify API responses by converting JSON data into Ruby objects, facilitating easier data manipulation through meaningful object definitions like 'Tweet' for Twitter API responses. - **Configuration Objects**: Leveraging OpenStruct to create configuration objects with a DSL-like syntax, allowing users to set and retrieve arbitrary keys conveniently. - **Test Doubles**: Employing OpenStruct to create mock objects that simulate complex dependencies, such as payment gateways, for testing purposes without the associated costs. - **Performance Issues**: Caplan highlights several shortcomings of OpenStruct, particularly its performance being 10 to 40 times slower than typical classes due to its reliance on Ruby's method_missing and method definitions. - **Improvements Introduced**: Caplan presents several alternatives to improve upon OpenStruct's inefficiencies: - **OpenFastStruct**: A faster variant that avoids method definitions for every attribute at the cost of breaking compatibility with nil behavior when accessing nonexistent keys. - **PersistentOpenStruct**: A middle ground that creates methods upon setting attributes but maintains better performance than standard OpenStruct. - **DynamicClass**: A significant innovation that dynamically defines instance methods based on provided attributes, further enhancing speed and usability over previous solutions. Caplan emphasizes the importance of continuous experimentation and benchmarking for developers, encouraging creativity to drive improvements in the Ruby ecosystem. He concludes with an empowering message, underscoring that anyone can contribute to the community through innovative problem-solving and collaborative growth. Overall, Caplan's talk underscores the balance between usability and performance enhancements in developing a better OpenStruct for Ruby, promoting a culture of experimentation and community contribution.
Suggest modifications
Cancel