That column by Joel Spolsky and Sean McGrath's response each gave me a big laugh. Thanks, titus, for posting that.
The funny thing about Joel Spolsky is that he's clearly an unusually smart guy, yet every piece of text he writes includes at least one remark that is fundamentally, laughably wrong. The more you think about them, the stranger they seem. Some of the columns actually depend on that wrong thing, and those are the truly comical ones. (He links to one of those from the column linked above.)
I approach each Spolsky column as a puzzle: spot the howler. You might think he puts them in on purpose, to see if you're paying attention, but no. Joel Spolsky has a big hole in his head. Whenever he gets too close, he falls in; but he can't see the hole, and he doesn't know when he's fallen in. Probably we all have one or more of those. The smarter you are, it seems, the more of them you have. (ESR has so many, and falls in so frequently, that it's not even fun spotting his howlers.)
What's wrong about this one? Well, plenty. For example, if he had used different enumerations for the different "kinds" of number in Excel, then the compiler would do the job he's promoting uglifying your code to do. The real howler in this one, though, is when he gets to exceptions, and he displays this bit of code:
When you have code that saysHere's a hint, Joel: a cleanup function in C++ code is a red flag with klaxons on. You don't have to look at dosomething() to know if cleanup() is "definitely called"; it isn't. (Neither is the code after it.) Now what? Joel, that's what destructors are for. He tosses another couple of howlers into the same paragraph, one about a "finally" clause -- as if that could make his code any better -- and another about checked exceptions, as if they actually worked, but enough. He's not telling us how to write exception-safe code, he's telling us exceptions are bad because he can't be bothered to write exception-safe code. (In C# or Java, he can't, really; but that's another essay.)your eyes tell you, what's wrong with that? ... The only way to know that cleanup() is definitely called is to investigate the entire call tree of dosomething() ...dosomething(); cleanup();
