When trying to explain the difference between dynamic typing and weak typing, I used to refer to this page (specifically the Addendum at the bottom). I still will - it's brief, but gets the point across.
For the long version, though, in future I'll refer to What the heck is: A type.
Posted to Software development by Simon Brunning at December 01, 2003 01:48 PMIt's interesting that that second article touts Perl as a *strongly* typed language. I've seen it described as weak before, and not without reason... "12" + 3?
Yeah, I noticed that. But the example he gave seemed to make sense, and I know virtually nothing about Perl, so I just let it slide...
Posted by: Simon Brunning on December 2, 2003 08:56 AMI knew that example would give people fits. However, it is correct. In perl "12" is not string data, nor is 3 integer data -- both are scalars, and all scalars can present an integer, floating point, and string representation of their value. The problem is not that perl is weakly typed (it isn't) rather that people misunderstand perl's type system. This doesn't necessarily make the type system good or bad, but it is still strongly typed. Feel free to take issue with the rich behaviour if its base types if you'd prefer. (Certainly a reasonable argument to make)
It was in there in part to try and get people to think twice about types, as they don't always represent what you think they do, nor behave in ways you think they might.
Posted by: Dan on December 2, 2003 08:14 PMHmm, that seems to make sense. Maybe I should study Perl's type system...
Posted by: Hans Nowak on December 3, 2003 03:31 AMDan, you did indeed make me think twice about types. Thanks. And if you say Perl is strongly typed, then that's good enough for me. As I said, I don't know anything about Perl.
I think I'll stick with Python's more intuitive types, though...
Posted by: Simon Brunning on December 3, 2003 09:29 AM