Views
- State: published
Dynamic Typing is Not a Panacea Either
|
|
Bruce Eckel chimes in on the Static vs Dynamic Typing debate. He writes in "Strong Typing vs Strong Testing":
That is to say, if a program compiles in a strong, statically typed language, it just means that it has passed some tests. It means that the syntax is guaranteed to be correct (Python checks syntax at compile time, as well. It just doesn't have as many syntax contraints). But there's no guarantee of correctness just because the compiler passes your code. If your code seems to run, that's also no guarantee of correctness.
The only guarantee of correctness, regardless of whether your language is strongly or weakly typed, is whether it passes all the tests that define the correctness of your program. And you have to write some of those tests yourself.
This is pointing out the obvious, compilation is no substitute for comprehensive testing!
The problem though with statically typed languages is that its all too easy to have this false sense of security that compilation is adequate testing. With dynamic typed languages, this sense of security is conspicuously absent, therefore most people are forced to write tests to validate their work.
However, it doesn't matter if you use a statically or dynamically typed language, you still have to write tests. But does the extra baggage of strict typing get in the way of productivity? I think there are pros and cons. The cons are that you have to type a little bit more. There's also a higher coupling between software modules because type information is spread out across the source code.
The pros I perceive is not what most would argue. It's actually based on my experience using the Visualage and Eclipse environments. The pros are that it's easier to navigate and search the code base. See the absence of type information makes it difficult to find the dependencies between code. Ask any smalltalker their experience of trying to reduce the size of the smalltalk image, it's an extremely painful process. Just because you're liberated today from type information, doesn't mean that it's not going to strike you back tommorrow.
The question you've got to ask is, should I sacrifice the code completion, quick-fix, search, etc. for a little fewer keystrokes?
Last modified 2003-07-30 04:14 PM



The problem though with statically typed languages is that its all too easy to have this false sense of security that compilation is adequate testing.
Another problem is that there are statically-checked languages which are not type-safe; which really makes the sense of security false. Some type safe languages: ML,Java,Smalltalk,Lisp