Static typing increases productivity and reduces errors

I’m going to come right out and say that I have a strong preference for static typing in a programming language, especially as it applies to medium and large sized applications with multiple developers. Here’s why:

1. Refactoring: IDE’s make huge refactoring jobs much easier largely because of static typing.
2. Catching errors at compile time rather than runtime: In a larger organization where unit test coverage can vary a bit it’s nice to know these more basic errors will be caught by the compiler.
3. Readability: I like seeing what classes are expected in a method signature, it makes figuring out a poorly documented API vastly easier, and lastly I like using my IDE to click on a method argument and hit a hot-key to jump over to that arguments class.

For me static typing is one more level of protection where I incur only a slight penalty in extra keyboard strokes for a huge time savings in refactoring, readability, and catching basic errors in out of the way places in the code base. Sure, I can develop slightly faster in a dynamically typed language but I can maintain and refactor the code faster in a statically typed language.

In most organizations it’s been my experience that unit test coverage will vary between departments. It certainly won’t exercise every single line of code in the system. When a developer refactors class X there will be those classes that use X that don’t get every line of code exercised in a unit test (MVC controllers seem to suffer from this a lot). If they’re in a lesser used area of a system and using a dynamically typed language, they’ll breeze right through QA and into production. I’ve never had this issue with a statically typed language but I’ve definitely seen several production code issues due to a refactoring of a project in a dynamically typed language.

I’ve heard the argument that dynamically typed languages are more productive, however, in my experience it’s more so that interpreted languages are more productive and less so because of static typing.

Anyhow, despite my bias for statically typed languages I’m itching for a project to use Ruby, its extremely compact syntax and great libraries just might make up for it’s lack of static typing 😉

This entry was posted in Java, Ruby, Software Engineering. Bookmark the permalink.