Immutability Matters
summary
A Ruby POC finds string constants mutate via << causing global path corruption and fixes it by applying freeze + concatenation or string interpolation; deep object freezing uses Ice Nine deep_freeze or the IceLine gem for recursive freeze. Immutable value objects follow three concrete rules: constructibility (init-only fields), equality (value-based equals, eql and hash), and single responsibility to avoid giant constructors. Libraries tested include Hamster and Values; RSpec HTTP aims for immutability but hits performance and deletion/caching tradeoffs in practice.
AI-written summary · about
chapters (11)
- 0:00Start
- 1:24Your code is full of immutability. Make it explicit.
- 6:26Equality - Henry G Baker
- 8:59Why Immutable Classes?
- 9:44Functional Core/ Imperative Shell
- 10:08Code Quality Code Reusability Safer from defects
- 10:50Simple Design Simple Test Concurrency Cyclic References
- 12:33Liabilities
- 14:09There is always a trade-off between performance and RUBYCONF
- 14:43Deletion is a form of mutation, cannot cache user data forever.
- 17:40Frameworks
related talks
26mImmutable Ruby
39mImmutable Ruby
38mImmutability is everything!
42mTaking inspiration from the functional world
19mThe Harvey Dent Dilemma: Ruby's White Knight Rises (or Falls)
35mChanging the Unchangeable: The Hows and Whys of Immutable Data Structures
25mLaziness is a Virtue: Lazy, Functional, Immutable Ruby
33mBetter Ruby through Functional Programming
