Warnings highlight possible bugs. The presence of a warning does not necessarily indicate a bug.
Only valid constructs will generate warnings! If a construct were invalid, then the system would have issued an error.
Warnings are not only for new learners. Warnings are also useful to experts, especially in the context of an evolving system. Delegating vigilance to the environment alleviates the burden of maintenance.
Changing code to cease its issuance of warnings usually requires disambiguation. This disambiguation is beneficial, because unambiguous code is clearer than ambiguous code. Encode your intent so that current collaborators and future maintainers will not have to guess at it.
If you truly require your code to run without warnings, then disable warnings entirely. The creation of warnings for potentially misleading or unexpected behavior should never require a battle. Existing code will not become incorrect, because warnings are not errors. However, you should still strive to correct the problems that issue warnings in new and maintained code.
edit: Some have missed the point of this post. I am not saying that having your code spew warnings is good in itself. I'm saying that having some warnings to alert you to suspicious code and to guide your fixes is what is good.
Existing code will not become incorrect
Well... It depends on what you mean.
Some warnings, for example with an unclean conversion of a string to a number, or use of uninitialized value
, depends on your data, and when you're parsing data, the structure of that data may change over time, because after a year, people that entered the data may have changed some conventions. That way, you may suddenly start to get warnings where you never got them before. And more often than not, that is a reliable indication that things have gone wrong.
Re:Code rot
mpeters on 2009-04-15T13:54:34
That's not existing code becoming incorrect, that's new data being incorrect.