From: dblack@... Date: 2006-11-13T03:01:21+09:00 Subject: Re: McGovern Likes JRuby... Hi -- On Sun, 12 Nov 2006, David Vallner wrote: > Running on Java would of course do bugger all for that. However, I am > one of the proponents of -some- (optional) ahead-of-time contract > checking for Ruby. Static typing is one method of contract checking, and > an easy one to implement, and in optional form wouldn't be rubbing me > the wrong way. YMMV, and it's a vapourware proposition anyway - IIRC, it > was pondered for Ruby 2.0, but there's no sign of that in any material > describing Ruby 1.9 changes, so I'm not holding my breath. > > Duck typing fans will probably howl over the above comment, but if I've > seen code behaviour do -any- type checking (mostly in the standard lib), > it's based on #is_a?, and not on #respond_to?, so apparently most duck > typing preachers really mean "I don't want to bother with any checks". I can't speak to the preaching and howling, neither being much in my line; but just in terms of the technical stuff: "duck typing" is a name for a style of programming that does not branch on an object's class/module ancestry and which may, but does not always, branch on an object's type, generally using #respond_to? when it does so. #respond_to? is not the heart of duck typing, though, nor consubstantial with it. It's a useful duck-typing tool, sometimes, but that's about all. In the past I've described the difference between using and not using #respond_to? as the difference between "soft" and "hard" duck typing. By that, I mean that the real business of duck typing is to live as close to the object, and to the present-time of the sending of the message, as possible; and respond_to? is a step away from that moment, therefore arguably a "softening" of the practice. But it's still duck typing, in the sense that the step away is still directly related to the goal of sending the object a message. The flip side of this is that the absence of #respond_to? does not mean the presence of duck typing. David -- David A. Black | dblack@rubypal.com Author of "Ruby for Rails" [1] | Ruby/Rails training & consultancy [3] DABlog (DAB's Weblog) [2] | Co-director, Ruby Central, Inc. [4] [1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com [2] http://dablog.rubypal.com | [4] http://www.rubycentral.org