Bruce Eckel (of Thinking in Java fame) writes about why static typing is pretty much redundant if you are unit testing properly - Strong Typing vs. Strong Testing.
It got to be said, though, that statically typed languages have one big advantage over dynamically typed ones - their GUIs can provide much better auto-completion. This was mentioned on c.l.py recently, but I'm not sure that I agree with Martin's view that this can be fixed. Imagine that you'd entered this:
def myFunction(anArgument):
anArgument.
At this point, which methods can your IDE suggest? Pretty much none at all, I'd say.
Not, I hasten to add, that I think that this advantage of static typing overrides the advantages that dynamic typing can give you - see Bruce's post for that side of the story, expressed rather better that I ever could hope to do.
Posted to Python by Simon Brunning at May 08, 2003 01:13 PMAt that point, in comes type inference.
Posted by: Paul Boddie on May 9, 2003 02:28 PMAnd what, prey, can be inferred from the fragment above?
;-)
Posted by: Simon on May 9, 2003 02:54 PMWell, nothing can be inferred from THAT snippet, but if you typed this:
def myFunction(aWidget):
[indent]aWidget.
then there's something to work with. To speak more plainly, when programmers are writing, they sometimes write extremely general code intended to operate on absolutely any type. But that's really quite rare. More often, they INTEND for the code to operate on certain types (perhaps the first param will be a Widget and the second will be a file open for reading). Now, dynamic typing allows us to hand in other things so long as they support the necessary interface (perhaps we pass a cStringIO instead of the open file), but there's still an expectation of what will be passed.
The problem for auto-completion is that the programmer doesn't declare the types, so seems there's nothing for the editor to work from. But in fact, most variables have a sort of "soft" type declaration -- usually done through choice of names. You name your widgets "aWidget", or "widget", or sometimes "w", but never "fred". You use "i" for arbitrary loop counters and not really for anything else. Your strings may have meaningful names like "customerFirstName", or when operated on in the abstract, they become simply "s".
Well, if your type inference works based on variable name, then it's able to pick up on these cues. Of course it still can't be as useful as in a staticly typed language, but it's far from useless, except in artificial situations like the one you give.
PS: someone please tell me how to enter indented python code in this forum!
Posted by: mcherm on May 12, 2003 03:10 PMblonde boy snowboarding ebony domina mens penis amd balls sis- video card- needed for 3d device
Posted by: Dimka on October 27, 2008 07:14 AMfree gay jerk offf oldlady fuck girl scout uniforms tulare horse cock penetration
Posted by: Alina_m on October 29, 2008 05:32 AMPosted by: Alina_m on October 30, 2008 03:17 AM
Posted by: Alina_m on November 1, 2008 03:28 AM
Posted by: Alina_m on November 4, 2008 06:55 PM
Posted by: Alina_m on November 4, 2008 06:55 PM
Posted by: Asina on December 2, 2008 07:41 PM
Posted by: Semil on December 6, 2008 02:58 AM
Posted by: Semil on December 6, 2008 02:58 AM