From: Hal Fulton Date: 2004-05-18T13:06:21+09:00 Subject: Re: How to duck type? - the psychology of static typing in Ruby James Britt wrote: >> Rather than trying to make Ruby do Static Typing because one is from a >> Static Typing background and that's what one is comfortable with, one >> should become comfortable with the dynamic nature of Ruby instead. > > > But why? > > That's somewhat rhetorical; I'm happier with duck typing, but there > seems to be two issues here. One is understanding what ducking typing > is. The other is understanding what it buys you over static typing. Well, this is partly a side issue. Like many people, I learned BASIC first. Then I learned FORTRAN. Then a smattering of ALGOL. Then Pascal (finally a language with lowercase letters in its name). Then C. Then Object Pascal, C++, Java. And so on. I hate to admit it, but all through my career, since high school, I took it for granted that the elements of an array were all of the same type. Sure, you can have an array of pointers. You can even do that in C, which is another way of saying you can do it in assembly language. But a full-fledged, ordinary, everyday array... with mixed types? Numbers and objects and strings, oh my! Of course, my education could have been broader, and probably should have been. But imagine my joy when it dawned on me that this was for the convenience of the compiler writer, not the programmer. That was on learning Ruby in 1999. It ain't duck typing. But it is dynamic typing. Would I do without it again? Only for pay. Hal