|
Re: Programming with "Duh" Typing
|
Posted: Jul 30, 2007 6:49 AM
|
|
> > But it does not mean anything that the code passed > > compiling. You have to run it afterwards, haven't you? > and > > that's my point: since you are going to run it, why > bother > > with static typing and even compilation? just run the > > program and correct it as you go. It's a much more > > rewarding experience. > > Achilleas, I mean no offense, but at this point, it just > seems like there is an uncrossable gap between you and > people who are trying to show you the benefits of > statically typed languages. I'm seriously running out of > ways to phrase my arguments, but I'll try one more: > > Statically typed languages allow you to write less tests.
My opinion is different: they don't help you write less tests. The number of tests to be written is independent of the type system, it depends on the requirements.
> > Surely, that's something that you can see value in? > > When you rename a function in a dynamically typed > language, you'd better hope that all your existing tests > exercise all the possible code paths that might invoke > that function, or you just broke your code in ways that > might not be apparent for months (or even after shipping).
Unless you do functional testing which covers 100% all the requirements.
> > > Not only is writing these tests extra work for you, it's > also error prone since it requires human intervention: > you need to understand the code you are refactoring.
You also need to understand the code in statically typed languages as well, especially when the types at hand are interfaces.
> > Renaming a method in a statically typed language requires > zero tests. Once the refactoring is over, you know for > sure that your code is just as correct as it was before, > and that's a certainty you can never have with a > dynamically typed language. > > As much as I enjoy writing tests for my code and thereby > guaranteeing that my program is working as intended, the > less tests I write, the more time I have to write code > that might benefit my users more directly (or play World > of Warcraft). > > -- > Cedric > http://testng.org
Well, I want to agree with you, but reality proves otherwise. Time and again, the bugs I have in my programs are not caught by the compiler, even though I use C++ and Java.
Only yesterday I had a serious error which was in a test version sent to the customer, just because I was bored to run the whole series of tests.
The error was that the number of possible values of a field of a message was changed. This number was used as an index into a table. When the relevant message was received, the table had less entries than the value, and the C++ application died a painful death.
The offending table was used in a secondary case that I had forgotten it ever existed. I changed all code of the main cases, tested it all, shipped a test version to the customer, only to get a complain that "it crashes".
The static type system did nothing to prevent this.
A fully dependent type system would have caught this error at compile time.
Unless static type systems become fully dependent, they are not very practical.
So I prefer dynamic systems with interactive development, which cuts the development time at least by half, instead of the endless cycle of edit-compile-run-debug.
|
|