On Sunday, December 12, 2004, 9:06:16 AM, zuzu wrote:

>> string.puts(STDOUT) creates a coupling, the string must call a method of the
>> given object with itself as the argument. It must know that the object it's
>> passed responds to #puts.

> i think to me this seems natural for the pure-OO "everything is an
> object" nature of ruby (or  smalltalk).  strings know how to display
> themselves, they just need to know where.  again, i think "naked
> objects" is the latest way to talk about this, though i often think of
> self language which was built on smalltalk.

I'm not normally given to this kind of negative exuberance, but ...

  ... that is just ABSURD!!!

Do you seriously think a string should know how to output itself to
the console, a graphics canvas, a printer, a fax machine, a network
connection, a sky-writing aeroplane, and every other bloody output
device!!?!?!?

In Ruby, everything is already an object.  The output devices
included.  Let's leave the details of rendering output to them and
them alone, shall we?

Claiming that #puts is polluting the OO nature of Ruby (perhaps noone
has done this, but they compare it to legacy procedural languages) is
sheer bloody madness.  What do I love about Ruby?

  def output_something(out=STDOUT)
    ...
    out.puts "something"
    ...
  end

  output_something(STDERR)
  output_something(StringIO.new)
  output_something(Socket.open)
  output_something(File.open)
  output_something(FaxMachine.discover)
  output_something(SkyWriter.yeah_right)

Having a pure OO language delivers us great practical benefit.  Let's
keep it that way, and keep enjoying _practical_ benefits rather than,
in the name of purity, turn all our objects into politicians who
endlessly defer responsibility for actually doing anything.

Sorry for any harshness.  This kind of discussion just drives me round
the bend.  And that's not fair, because it's the people with the crazy
ideas that bring progress.  ("Whaddaya mean, you can add methods to
existing classes, you nutjob?")

Cheers,
Gavin