From: Joel VanderWerf Date: 2010-11-13T03:08:11+09:00 Subject: Re: Ruby vs PHP for the web On 11/12/2010 08:35 AM, Mike Stephens wrote: > Robert Klemme wrote in post #960960: >> >> >> There seems to be some disagreement what exactly "strongly" and >> "weakly" means here. > > To me it's pretty straightforward. An object of Class A cannot be > treated as an object of Class B - the language system detects and > prevents this. Ruby does not follow this approach. It uses duck typing > which is the opposite. What makes this so slippery a question is what "treat as" means. Does a = [1,2,3] s = "count = #{a.length}" mean that a Fixnum is treated as a String? It may look so at first glance. But what's really happening is that #to_s is called on the Fixnum. So String interpolation is using, as you say, duck typing, to convert types. I don't really know whether this counts as "treat as" or not. IMO, the most clear-cut example of weak typing is this: $ cat a.c #include main(){ float x = 1.23; printf("%d\n", (int)x); printf("%d\n", *(int*)&x); } $ gcc a.c $ ./a.out 1 1067282596 Not even perl is weakly typed, in this sense.