We are all familiar with the standard advice. Use strict.pm . It catches typos.

But have you noticed that most other scripting languages don't agree with us? If you look at JavaScript, PHP, Ruby and Python you will look in vain for any corresponding piece of standard advice that makes variable declarations required. Why is this?

My theory is that it is an over-reaction to statically typed languages. When you come from a world where you are used to typing:

FooBar fooBar = new FooBar(); [download]

over and over again it is easy to overreact to the realization that constantly declaring types gave you no real benefit. It is more convenient to not declare the types at all, so why not go all of the way and remove the declaration entirely?

As we all know, the answer is that the answer is that the apparent convenience is misleading. Required declarations automatically catch a class of real bugs for you. Not requiring declarations forces eternal vigilance. As I noted in Re: Avoiding silly programming mistakes, eternal vigilance is a bad thing.

However it seems to me that Perl programmers have less cause to be smug than might appear. It seems to me that as a culture we have internalized the practice, but not the principle.