Is Static Typing the Root of All Evil?

Anders Janmyr has written recently an interesting article why he hates static typing:

Donald Knuth wrote in his famous paper Structured Programming with go to Statements (PDF)

We should forget about small efficiencies, say about 97% of the time: pre-mature optimization is the root of all evil

Since compilation is premature optimization, it is therefore, the root of all evil. Simple!

Pretty "smart" reasoning but stupid, IMHO.

He mentioned: "Every time I build my code, my entire code base is type-checked (…) I only care about the method and class that I am currently working on" – yeah, local code change may introduce errors in unexpected parts of a system. I would even use FindBugs if it will improve code quality and slow down total build time. Why? Because I think it's better to allow compiler/lint-tool to control correctness during development process to find most errors as early as possible.

Janmyr assumes the only application of static typing for release preparation (production mode) is better software optimisation. Compiled languages are more efficient than interpreted because many type checks was performed during compile time time and they can be removed from run-time.

I do believe dynamically-typed languages are faster for rapid development (I do love Python, BTW), but there's a hidden cost here. In order to make your code maintainable you have to prepare sufficient level of unit test coverage (I'm using 80% as minumul level for projects in dynamic languages). That's why i'm introducing some kind of static typing by:

I do agree, however, that modern languages are loosing static type-safety by moving configuration outside Java code (XML files, properties, Json) and coding logic in external dynamic sub-languages (JSP). Java gets more type safety from 1.5+ language contructs but most frameworks go in opposite direction.

Isn't Dynamic Typing the Root of All Evil then?

Duck Typing Ducks?

This entry was posted in en and tagged . Bookmark the permalink.

One Response to Is Static Typing the Root of All Evil?

  1. Michał says:

    While learning programming I once was moving from PHP, which has pretty much no typing, to Java, which has full typing. Back then that move was all but easy and I kept complaining on why Java has to make it so hard to manipulate data of various types. I did get through that though and now I find it hard to work with typeless languages again.

    It's simply that Java offers many constraints, thus allowing programmers to apply plenty of checks for whether data passed on is correct. This in turn protects us from hurting ourselves accidentally and thus we can code with more certainty that we won't break anything that elementary.

    Working with ColdFusion right now I constantly need to use functions like IsArray, IsBoolean etc. Checking for whether my data is what I expect it to be.

Comments are closed.