This post originated from an RSS feed registered with Agile Buzz
by James Robertson.
Original Post: Type Errors redux
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
There's been a bunch of comments on this post and this post - both on Dynamic typing vs. Static typing. The static language argument that seems to come up over and over again can be summarized thusly: Better Safe than Sorry. For instance, with the vehicle/road analogy raised by Peter Lount, I saw this comment:
Dunno what sort of world you're programming in... but lets see... four extra days of programming time versus losing $1,000,000 on that bank transfer... or not notifying the customer of their flight change... or landing that plane 4 metres BELOW ground level hmmmmm... in programming, safer == better. ALWAYS. Because the impact of extra programming time is known and controllable. The impact of an unexpected bug is NOT.
That's the argument I hear over and over again. But "safety" is relative. We ask for certain levels of safety, but we trade it off vs. pragmatism. For instance - we could all be much safer if we mandated that everyone drive in minvans at 25 mph. Do we mandate that? No, because we have to look at the other issues (Do I really need a vehicle that large? What if I want to get somewhere in a reasonable interval of time?). Sure, we have some roads that forbid trucks and bicycles - but most don't. We make tradeoffs so that we can have a reasonable level of safety vs. a reasonable level of productivity
You can apply this to almost any field you want - take medicine. You can increase the level of safety by having longer testing periods (simulations, animal testing, etc) - but in the meantime, the people who might be saved by the drug aren't being helped. Do we allow safety to trump pragmatism here? No, we attempt a reasonable tradeoff.
There's another issue here as well - there's no actual evidence that statically typed systems prevent catastropic failures. The Ariane V, for instance - that was a failure caused by lack of understanding and improper module usage - static typing did not prevent the explosion. Algorithmic errors - the sorts that are most likely to cause huge failures - are not going to be caught by a compiler. Subtracting the wrong numbers (and having the compiler chirp happily because they are both ints) won't help me if they are the wrong variables to subtract. You need testing, not irrelevant (and falsely comforting) static typing.
Stating that we must be safe (i.e., use static typing) is an over-extension of the "precautionary principle". It advocates doing nothing that could possibly bring harm. If that's your argument, you need to stop coding now - because static typing isn't going to help you. What you want is formal proof that your application is "safe". Good luck getting there...