May 08, 2003
Strong Typing vs. Strong Testing
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:
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 PM
At that point, in comes type inference.
And what, prey, can be inferred from the fragment above?
Well, nothing can be inferred from THAT snippet, but if you typed this:
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!
blonde boy snowboarding ebony domina mens penis amd balls sis- video card- needed for 3d device
free gay jerk offf oldlady fuck girl scout uniforms tulare horse cock penetration