Testing is important, even in statically typed languages

I was planning a blog post about how much I hate the debug, fix, build cycle of statically typed langauges, especially when you have a lengthy compile-time (AspectJ really makes you pay a high cost for this when you change a deep-touching pointcut).

But then I had stuff stop working for me because of the hacky nature that my supervisor and I have been adding stuff. And with no tests, I am not sure when certain things just ceased to work. This whole thing came together so quickly and was under such a state of flux I never took the time to learn how to do proper unit testing for Java/AspectJ (I am assuming junit is still the best bet; if you know of something better please leave a comment) since I have not seriously coded in Java in years.

Anyway, Titus had a post about how some GNOME developers said they didn't always like programming in Python because "you have to be very diligent about unit tests and code coverage". But as another post at another blog pointed out, you really should be doing this level of testing regardless of whether your compiler checks stuff. I completely agree and I am paying the price right now for not doing what I knew I should be doing.

I have argued before that the amount of time required to add tests specifically needed because of the use of a dynamic language is less compared to the amount of time you lose to compilation and what little help you get from type safety. I honestly think type safety should be viewed more as an opportunity for optimization and less as protection against errors.

But you still have the time loss to compilation if you do testing for a statically typed language. But the piece of mind and making sure you don't introduce regressions is just worth it.