News for hackers. Stuff that matters.
Re:"DCI" in Ruby is completely broken by eduardordm on Wednesday January 02, 2013 @11:58AM (#4997600)
Ruby is a language, not an implementation. DCI in ruby seems just fine, but all implementations are not friendly to the dynamic mixin hell hole.
Re:"DCI" in Ruby is completely broken by latortuga on Wednesday January 02, 2013 @12:05PM (#4997644)
Completely agreed, the title is a red herring and serves to dissuade people from giving DCI a try. "It's too slow" is not an argument against DCI, it's an argument for fixing a slow implementation of #extend or using a different method.
Re:"DCI" in Ruby is completely broken by bascule on Wednesday January 02, 2013 @12:27PM (#4997799)
Why not do DCI with delegation instead of mixins?
Re:"DCI" in Ruby is completely broken by davnola on Wednesday January 02, 2013 @04:22PM (#4999394)
Because in general, delegation tends to lead to object schizophrenia. Specifically, SimpleDelegator will leak the original delegatee object when a delegated method returns `self`.

     s = "foo"
     
     d = SimpleDelegator.new s

     s2 = d << "bar"

     s2.object_id == s # true
I think SimpleDelegator is really neat but totally dangerous. Doesn't this ring alarm bells with you?

  # delegate.rb L117
  #
  # Returns true if two objects are considered of equal value.
  #
  def ==(obj)
    return true if obj.equal?(self)
    self.__getobj__ == obj
  end
Re:"DCI" in Ruby is completely broken by bascule on Wednesday January 02, 2013 @12:08PM (#4997673)
While this is true, it currently has pathological performance on all major Ruby implementations.
Re:"DCI" in Ruby is completely broken by eduardordm on Wednesday January 02, 2013 @12:19PM (#4997751)
I just wonder if fixing this (by adding extend calls to cache) will end up making unicorn eat way too much memory.
Re:"DCI" in Ruby is completely broken by mst on Wednesday January 02, 2013 @03:37PM (#4999110)
The perl equivalent (run-time role application) normally caches the extended class by default and re-uses it. Provided you don't have a pathological number of combinations, that seems to work out pretty well.
Re:"DCI" in Ruby is completely broken by mrgoldenbrown on Wednesday January 02, 2013 @12:41PM (#4997902)
When you say "it" you mean using extend, not DCI in general, right?
Re:"DCI" in Ruby is completely broken by bascule on Wednesday January 02, 2013 @01:00PM (#4998038)
Yes, hence why I was constantly calling it "DCI" in quotes