Hmm -
Erik writes that he doesn't like dynamic languages after moving
from Python to Ocaml:
This particular error is typical of a whole class of
errors that can exist in dynamically typed programs
[0] but may never show up until the program is in the hands of a
user. Personally, I think programs blowing up like this in the
hands of users is unacceptable. Unfortunately, its also extremely
common; so common that most regular computer users would have
experienced things like this at least once. To me, this is a
failure of discipline of software engineering.
Here's his error:
try:
data = my_obj.read (1024)
except:
print "Read on '%s' failed" & my_obj.name ()
The error is the ampersand in the exception handler, which didn't hit until the first error. Well, that's why we have testing in general, and unit testing in particular. Personally, I find that specific kind of error rare, but it would be caught immediately with a small test.
What did he do wrong? Well, under what circumstances would you put a data read/entry function into an application and deploy it without testing how it deals with bad data? Seriously - this is not a problem that type checking will solve for you very often - the much more common error I've had in my own code is a correct statement with logic problems - something a compiler won't catch (what do you mean I can't write a file there?).
The problem he talks about is not, in general, one that you can solve with type checks. It's one you can solve with testing. Getting more feedback from the compiler may help him feel better, but it won't actually help much.
Technorati Tags:
dynamic, static