A thought on static types vs. dynamic types

The simple fact is, I would never choose to write shell scripts in a strongly type-checked language (unless someone were to write a scripting language that is as cheap and dirty as, say, bash). And I would never use a torque wrench to change a light bulb in my house when a crescent is handy. Type checking simply isn't a critical feature for the scripts that I write, and there is a certain cost in using languages that check types rigorously.
On the other hand, I would never be fully confident in a large system built on a DT (Dynamic Type) language. It's not because I don't trust the language. It's because I don't trust myself. An ST (Static Type) language constrains the types of things you can say in a way that helps you avoid erroneous constructions. But the cost is that you have to consciously choose the types, and sometimes you have to build the types from scratch. This cost is not zero, and it's not negligible, which is why I prefer to write shell scripts in an untyped language.
But the larger the system, the more the type system of a language gives me confidence that the components are being used correctly. Since tests get more expensive to write the larger the pieces to be tested become, it is very nice to have the compiler tell me right away that I've done something stupid or made a simple error than to wait for a test to tell me that. Although type checking does not necessarily imply correctness, for many types of algorithmically simple program components, it gets you 90% of the way there.

“Johnny Come Lately [1]”

Which pretty much sums up why I prefer to use statically typed langauges (I was probably the only one in college that liked programming in Ada). I tend to think of programmers that prefer dynamic typed languages as sloppy thinkers, but perhaps that's because all the languages I learned early on were statically typed (especially Assembly were you had to explicitely reserve memory for your variables).

[1] http://lambda-the-/

Gemini Mention this post

Contact the author