Monday, February 04, 2008

Static typing considered harmful

(Updated Info, 2014-10-29)
I still find almost no value in the static typing provided by Java. That said, I've done some ML lately and been very impressed with what types can provide. In addition, I've worked with some great programmers who do find value in Java's static typing.

If you take anything away from this blog entry, I would recommend this: No one can tell you which tools will make you the most effective, try them all and determine for yourself what helps you the most.

(Original Post, 2008-04-02)
Given a good test suite the return on investment simply does not justify the use of static typing.
In 5 years, we'll view compilation as the weakest form of unit testing. -- Stuart Halloway
Type verification provides very little confidence that an application works. The little confidence it does provide comes at the cost of being confined by the type system. Verifying types is better than testing nothing at all. But, only verifying types is insufficient for application development.

The obvious answer is to write more tests. As you write more tests, you can verify independent pieces of the application and integration of the different pieces of the application. Currently, you know that your code compiles; but that is to general to be considered sufficient for verifying system behavior. Specific tests can verify specific behavior. You may start out testing that 1 + 1 is a number, but eventually you will be better off testing that 1 + 1 is 2. The test that 1 + 1 is a number may have given you some confidence that your application was working, but once you add a test to verify that 1 + 1 is 2, the test that verifies that 1 + 1 is a number no longer provides you with any additional confidence. Since the test that verifies 1 + 1 is a number no longer provides any value, it can safely be removed.
Post a Comment