From: Lloyd Zusman Date: 2001-07-23T21:03:34+09:00 Subject: [ruby-talk:18335] Re: Ruby, Python and Objects philosophy Quoting Joe Graham : > Wasn't there a big /. discussion about this a week or so ago? If I > may interject some thoughts into this matter as well. Regretfully > it belongs on page 75 of that old slashdot discussion but how could > I resist? > *** Warning, below is pure opionated sputter. Read or discard as > needed *** I have decided to take your "read" option, which has turned out to be an amply worthwhile decision. > [ ... lots of interesting stuff snipped to save space ... ] > > [ ... ] Every program I get paid to > work on involves some custom logging mechanism and whoever I work > for has some brilliant idea on this new fancy logging framework > that�s going to tell you everything about stupid program X. > > Method defintion( some params ) > LogMethodEntry( Hard_code_method_name_or_something ) > Try: > Wow_my_code_finally_goes_here > Catch: > LogThatProblem( Send_That_Error_All_Unformatted_and_ugly_to_our_logger > ) > Finally: > LogMethodExit( Hard_coded_method_name ) > > [ ... more good stuff snipped ... ] > > [ ... ] So what is the alternative? If I can override > the default behavior of all objects in stupid program X than I can have it > �describe� itself to the logger without writing all that duplicate ugly > code. [ ... ] > > ..method definition > #note� someMethod exhibits error trapping behavior > someMethod( some params ) > # logging is take care of by Class! > Do_my_work_here > > �.outside method call > catch( methodProblem ) > tell_FailBlock( what, where ) > send_methodProblem_back_to_sender > > > Now isn�t that pretty? Notice the missing duplicate code? Assuming of > course that we can have objects interested only "aspects" of what is going > on take care of those things and the code does not have to be duplicated. > In this case the "aspect" is logging method behavior. > > [ ... ] Also I can get paid big bucks today programming in > languages like Java that really limit what I can do at runtime. (ouch!) > This is not the case with Ruby or Smalltalk. So what difference does it > make to the would-be Ruby fleeing from Python / Java / VB or whatever > programmer? The answer for me would be �What difference would I want it to > make?� Can you make Python act like ruby? (yes!) Can you make Ruby act > like Python? (yes!) Can you even get those cool block thingies in Python? > (well you have anonymous functions and if you are really good at tricking > yourself, yes!) You have made some good points and illustrated them well. And I mostly agree with the opinions you have expounded upon in your sermon. And now, I have a question: could you show us how the example above would be coded in Ruby? Your pseudo-code is very nice, but a good, concrete, totally runnable Ruby example of the exact logging scenario that you have spoken about would be even better. Thank you very much, in advance. > [ ... ] -- Lloyd Zusman ljz@asfast.com