|
Note: This is a single entry from my online diary. Please note that I'm not always entirely serious and some entries probably won't make sense unless put in context with other entries. |
|
I should have done this long ago, and would like to encourage all Perl programmers to do something like this themselves. The is especially important for Perl code, because although Perl is in many ways an excellent language it is not strongly typed and it allows code to be generated at runtime. This means that the compiler (or interpretor, in this case) can only check some very basic things when you compile the program - many errors cannot be caught until the program actually executes the broken code. If the broken code is rarely used, then you can expect unexpected crashes... so ideally, when you write a Perl program you should also implement and maintain a set of tests that force every single line of code to execute at least once.
The fact that this is necessary at all is one of many good reasons some people think Perl is a Bad Language.
The critics do have a point - but I like Perl anyway. It's a powerful, comfy language. The very features that make it more error prone facilitate very elegant implementations sometimes. You just have to be careful - and even if Perl didn't have these flaws, then you would want test-cases, since they provide assurance that ongoing development doesn't accidentally alter the behavior of the program.