Static Typing vs. Testing
Michael Tsai, who is on a blogging roll lately, has a great rundown on the latest kerfuffle about static typed languages like Swift and whether their value outweighs their inconvenience.
The underlying problem is simple. In dynamically-typed languages like Obejctive C, you can have a container that holds different kinds of things and, if you get mixed up, you might find yourself sending a message to an object that it can’t handle. If you’ve got a mix of Dates and Colors in the same list, you might send a color an request for its day of the week; if you do that, the color looks at you all funny and nothing good will happen.
Reading this debate, I was startled to realize one thing I’d overlooked: I almost never make type errors. I make plenty of errors – for me, programming is always about correcting errors – but type errors are once in a blue moon affairs.
I wonder if strong typing is a solution to a problem we don’t really have, or whether I’m just Doing It Wrong.