Refinements - The Worst Feature You Ever Loved
summary
Refinements aim to make monkey patching local by letting code declare and using scoped method overrides, but early dynamic scoping makes method lookup invalidate the method cache and costs about a 20% slowdown. Changing to lexical scoping preserves performance but prevents refinements from reactivating when a class is reopened, breaks interactive eval (pry/IRB line-by-line), and removes the Rails/DSL convenience use cases, so the feature exists but rarely gets adopted.
AI-written summary · about
chapters (10)
- 0:00Introduction to refinements
- 3:11What is monkey patching
- 8:57Problem refinements solve
- 12:09How refinements work
- 15:00Dynamic scope issues
- 18:41Confusing and dangerous behavior
- 21:00Performance impact of refinements
- 25:56Lexical scope solution
- 31:22Trade-offs of lexical scope
- 34:44Final verdict on refinements
related talks
30mRefinements - the Worst Feature You Ever Loved
32mRefinements - the Worst Feature You Ever Loved
42mWhy is nobody using Refinements?
47mClassboxes, nested methods, and real private methods
53mRuby 2 in Ruby on Rails
12mImpactful Refactors: Refactoring for Readability
29mLet’s refactor some Ruby code
32m'method_missing' Should be Missing
