4 ms·
Totally agree about refinements. Hopefully the community pushes back enough on that experiment so it gets deprecated and removed. A better design approach to a
by jacquesc 14y ago
Totally agree about refinements. Hopefully the community pushes back enough on that experiment so it gets deprecated and removed.
A better design approach to achieve this effect is wrapper objects (similar to jQuery and Underscore.js) where I can add functionality to existing objects. Ruby has everything we need for this already, and makes it quite easy to do.
- nnq 14y agoAren't refinements a "fixer feature", i.e. something 99% of developers should just ignore it until they really get into a problem with badly done monkeypatching, then use it to solve the problem and just move on? Why do people get so excited about them, both in a good and in a bad way? Just use them inside your library code and make sure people using your lib/framework can just pretend they don't exist, keep monkeypatching "chained inside" as your dirty little secret:P)
- tomstuart 14y agoCharles Nutter does a good job of explaining why you can't just ignore refinements: http://blog.headius.com/2012/11/refining-ruby.html http://blog.headius.com/2012/11/refining-ruby.html In summary, they makes the Ruby language harder to implement, and Ruby code harder to understand. You can't pretend they don't exist if their existence compromises the meaning of your code and the performance of your chosen Ruby implementation.
- vidarh 14y agoBecause they make efficient implementation of Ruby, which is already an utter nightmare, substantially harder.
- riffraff 14y agobut ruby culture is already one of modifying builtins, so using wrappers while arguably better, does not solve the issue which refinements solve.
- djur 14y agoThere's been a substantial retreat from modifying builtins in library code in the last 1-2 years anyway.
- pjungwir 14y agoRefinements worry me too. They make it a lot harder to read and understand code, or track down where strange behavior is coming from. I wish I could just ignore them, but unfortunately libraries like ActiveRecord probably won't. And then there are the performance problems. Since so many people dislike them, I wonder what the community response will be? Will JRuby just leave them unimplemented? That seems bad, but I'm not sure I'd mind too much. But that's not viable if it means Rails and other things won't work on JRuby.