Sunday, October 10, 2010

Latent bugs in PHP

Static typing misses the more subtle bugs arising from legal but damaging expressions. For instance, the C language allowed assignments in conditionals, a "feature" which gave rise to terse code and the following hard to spot bug:

if (c = 1) {
printf("This condition will always evaluate as true.")

After looking at code for many hours, it is easy to forget that == is the comparison operator.

I recently discovered the same bug in a PHP script. Some features are not worth having in the language and are a risk in and of themselves.

No comments: