From: Austin Ziegler Date: 2006-11-12T13:35:05+09:00 Subject: Re: McGovern Likes JRuby... On 11/11/06, 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. That's good, because it would change Ruby from a beautiful language into the hell that is Java. There's *no* advantage to the programmer from explicit static typing, IME. (I've had more problems with statically typed languages than I've ever had with Perl, PHP, *or* Ruby.) > 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". This is disingenuous. There are certain things about the behaviours of intrinsic (core) objects (Array, String, Hash, etc.) which cannot be distinguished with #respond_to? in any way. If you look at most such checks, they're to distinguish between those specific types. Aside from that, there's much more likely to be #respond_to? checks outside of the core and standard libraries. My libraries, for example, tend to rarely check the class of something -- and when I *do* perform checks, it's generally for a #respond_to? call. I think that's true of One shouldn't need to perform most checks: they're a performance hit. If you tell people (through documentation) to send you something that responds to #<< then you just *use* #<<. If you want to print a custom message, then you perform the check. -austin -- Austin Ziegler * halostatue@gmail.com * http://www.halostatue.ca/ * austin@halostatue.ca * http://www.halostatue.ca/feed/ * austin@zieglers.ca