by kstenerud · 15y ago · 0 comments
Code that works the first time it's run is magical, and therein lies the problem: Magic code is untested and unproven code. It offers a false sense of security, which is why it fills experienced developers with a sense of dread.
Until you prove that code's correctness (such as with tests), it is almost certain that it has nasty bugs in it that your initial successful run haven't uncovered. So what does having it work the first time give you? Bragging rights, maybe, but nothing of any real value to shipping code.
It takes more time to prove the code than it does to write the code, and it generally takes more time to design the code than it takes to prove it.
Syntax errors are caught by the compiler, and are very quick to fix. Semantic errors are usually caught by compiler warnings (provided you turn them on) and by static analyzers, and are also quick and easy to fix. Anything more insidious will not be uncovered by code that "works" the first time it's run, so you really haven't saved yourself anything.
Fixing syntax errors will do nothing for the logic errors. I find it more plausible that fixing syntax errors coming from sloppy writing will rather cost you time and energy that would be better spent on making the logic right.