Originally posted: July 4th, 2007
(Note from July 2010: Yes, I know I refer to dynamic typing as "weak typing" here. "Weak typing" includes more than just C's implicit reinterpret casts. Dynamic typing IS a form of weak typing: deal with it.)
Years of condemnation to the seething underbelly of the programming world known as "web application development" has driven me to this plea:
Please, for the love of god, no more weak-typed languages!!! I can't take it anymore! That includes you too, duck-typing. (Yes, I realize many of those languages optionally allow strong types, but that's just a bandage, and often an afterthought.)
Here's the generalized rule of thumb these weak-typed languages are breaking:
Anything that CAN be handled at compile-time, SHOULD be handled at compile-time.
(Obviously, I'm counting "parsing interpreted-language code" as compile-time here.)
Why is this a good rule of thumb? For one thing, optimization. If you offload certain calculations (such as arithmetic on numerical literals, ie '2 + 3′) to the compilation process, then your program doesn't have to, thus speeding it up. Fortunately, this sort of thing is already handled by most compilers, so you don't have to worry about it. (If you're wondering: yes, I have come across one notable exception: SPIN)
But there's another more important reason for this rule of thumb: Bugs. Bugs are bad. There are two types of bugs: compile-time bugs and run-time bugs. Compile-time bugs are always brought to your attention automatically, whenever your code is compiled. That makes them easy to fix. Good bugs. Or at least as good as bugs get. Run-time bugs only show themselves if you're lucky. These bugs hide and fester. That makes them hard to fix. Bad bugs.
I don't like weak typing because, while it might seem to eliminate type concerns, all it really does is change the type errors from compile-time (good) errors into run-time (bad) errors. This may not be a problem when you're whipping up "Lil' Coder's First PHP Page", but when you have a full-blown web application to maintain, you'll just waste your time hunting down bugs that could have been pointed out to you the moment they were introduced.
Languages that religiously force everything into the latest silver-bullet paradigm have also got to go. I'm looking at you, Smalltalk and Java (Clarification: I like OOP. I don't like religious OOP.) Here's an excellent explanation of one of the reasons I can't stand Java.
As long as I'm ranting on languages, VB6 is obnoxiously verbose. (Yes, I know VB6 has been replaced by VB.NET. But I'm still condemned to it anyway.) Behold:
In most C-based languages:
int var = 5;
In VB6:
Dim var As Integer
var = 5
How clunky. I have other examples of VB insanity (yea, I know, who doesn't?), but they'll have to wait for now.
Read more