From: Elliott Hughes Date: 2004-03-11T00:18:00+09:00 Subject: Re: Duck typing chapter The second draft of the first few paragraphs is better than the first, but it still doesn't read well to someone firmly in the "static typing is a far, far better thing" camp. I think you'd probably be best off not getting into this argument. I think I'd miss out the whole section. If you don't, you need to address actual static typer concerns, not the straw men you present. For a good overview of what static typers are more likely to be thinking, have a look at Bill Venners' recent interview with Bjarne Stroustrup: http://www.artima.com/intv/abstreffi2.html I don't think you'll find many static typers have a problem with dynamism; but I personally have a major problem with dynamism as a default. With reflection in a static typing environment, I can say "I'm doing something unusual here, so relax some rules, and I'll pay very careful attention to this bit myself". So I have all the benefits of both worlds. In a Ruby-like environment I have to pay all the costs of dynamism despite the fact that I almost never gain any benefit from it; Ruby (unlike Perl) won't even tell me if I have an identifier appear only once in a program. Yes, one time in a million that might be because I'm doing something really cunning. But the other 1,000,000 - 1 times, it's an error. Perhaps your best choice is a pragmatic approach. Take me, for example: why do I use Ruby? "Because it's useful." So is it worth worrying about static typing versus dynamic typing? Not until someone offers me a better scripting language. "Ruby: Not Quite as Bad as Perl" may be damnation through faint praise, but it's enough to be going on with. On another note, I found the to_i/to_int section difficult. It might help if you chose one wording and stuck to it ("some kind of decent representation as", "can naturally be used every place", "a clear representation as", just added to my confusion). I also didn't understand when I'd use to_str instead of to_s, or what other classes than String would implement to_str, and I definitely don't understand what class would reasonably implement to_i but not to_int. This maybe because I'm a static typer at heart, but it seems a reasonable assumption that I won't be the only one reading Pickaxe2! -- Elliott Hughes, BlueArc Engineering -----Original Message----- From: Dave Thomas [mailto:dave@pragprog.com] Sent: 2004-03-05 06:02 To: ruby-core@ruby-lang.org Subject: Duck typing chapter I've posted a rough first pass at a chapter about duck typing (and other typing issues in Ruby). It covers - what a type is - duck typing - Ruby's built-in protocols (to_str, to_proc, etc) - coercion and double dispatch http://www.pragmaticprogrammer.com/extracts/ducktyping.pdf It isn't typeset, and I haven't really read it through for typos. I'd be interested to see what folks think. Again, all feedback gratefully received. Cheers Dave