Headius technical comments on ruby tracker are a must-read.
As my personal take, I am appalled at refinements. I think this is a bad idea solving the wrong problem.
Headius technical comments on ruby tracker are a must-read.
As my personal take, I am appalled at refinements. I think this is a bad idea solving the wrong problem.
class Foo < SomeParent
def baz(str)
cached = str.camelize
ary.map {|name| cached + name}
end
end
Could have a completely different meaning than this code: class Foo < SomeParent
def baz(str)
ary.map {|name| str.camelize + name}
end
end
/lights hair on fireHopefully a lot of the tweaks and refinement will come from now to Final 2.0 release.
LuaJIT is pretty much impossible in a language with as complex semantics as Ruby (it's probably impossible in Python already, and Ruby is significantly more complex)
Cause now not only do we have that confusing feature which very few people seem to like, it also underlines a worrying trend where the different parts of the Ruby world don't reach a consensus before going in radical directions.
No one summed it up better than Brian Ford at his RubyConf talk really: http://www.confreaks.com/videos/1278-rubyconf2012-toward-a-d...
It's a must-see.
http://www.confreaks.com/videos/1275-rubyconf2012-ruby-2-0-o...
The downside is it becomes even _harder_ to figure out what code is being run just by reading it. Right now, you just have superclasses and included modules, potentially gummed up by method_missing. Now, you need to also pay attention to refinements included by code that _calls_ the code you're looking at, which may change the way it behaves.
Unless used with great care, it's going to create a nightmare debugging situation. And with some of the code I've seen, it'll happen.
http://igor-alexandrov.github.com/blog/2012/11/05/yet-anothe...
I don't much like refinements, but conflicting monkey patches from different third party libraries _has_ been an issue over the years.
The ruby community is not even the first one to notice that, there is plenty of literature on "selector namespaces" and "classboxes" from the smalltalk crowd.
In my eyes, monkey patching should only ever be considered:
1. To fix outright bugs or nasty performance issues, where the monkey patch should not have other side effects.
2. In application code, never in libraries (except as a library explicitly providing monkey patches to an application, but never as a requirement for a library to work).
3. In adding new methods, except for case 1.
Of course there'd be exceptions, but very little monkey patching I see in library code is necessary or worth it.
Inside your library, you have plenty of ways of avoiding the need: Wrap objects; convert objects; use helpers. Yes, it might not look as perfectly smooth, but I'd take that over trying to reason about code that relies on different sets of refinements in different scopes any day..