2003.10.13 11:06 PM
Joel Spolsky in Error
Are exceptions a bad thing? I don't think so. Oh, I used to, back in the old days of VB3, FoxPro, and even Pick Basic. But even then it was due to a lack of robust error handling facilities in those environments, or because I was interacting with a lot of error-code-returning APIs and didn't want to muddy things up with a different error handling style.
Things have changed a lot since then. With the exception, it seems, of Mr. Spolsky. He has just written that "exceptions [are] no better than "goto's"". Yikes.
I'm not going to pretend I can make a good intellectual argument for the use of exceptions (especially at 1AM), so instead I'll reference the best one I've read in recent memory. This excellent "rationale for exceptions" comes to us by way of Brad Adams, with help from Jason Clark.
It's a little unsettling seeing someone whose opinion I respect and admire so much coming down so hard on the opposite side of an issue from me like this. I know there's room in development for every opinion and approach, but still it's weird. I've read his post three times now, and the only feeling I can muster for it is a tiny bit of empathy for how his opinion may have been formed (and perhaps for the constrained development context that may allow it to persist). But I really can't appreciate or share the opinion at all.
My guess is that Mr. Spolsky will soon recognize and expound on the virtues of well-mannered structured exception handling, or he will say "just kidding!" while explaining that he only meant to create a topic about which all of us obscure bloggers could cross-link and trackback to ourselves in order to increase our intra-community traffic.
By the way, check out the comments Mr. Spolsky is generating in his own forums. There are too many to link, but here's an interesting thread. I'm not sure what's funnier, the posts suggesting the site was hacked, or the couple of folks who actually agree with Mr. Spolsky's position.
Mr. Spolsky speaks, sort of:
I guess we can conclude from this that his earlier comments were not an April Fool's joke or unfortunate site hack.
However, his saying now that talking about exception handling as "good vs. bad" is tantamount to a "religous debate" hardly satisfies one's desire for the real poop on his original comment that exceptions "are significantly worse than goto's". Nor does it explain his bestowing on us a "better alternative" that, by his own admission, is "ugly and annoying".
ewbi.develops | 2003.10.14 10:44 PM
The thing is that exceptions work incredibly well in the context of a framework designed to embrace the exception model at a deep level, and incredibly poorly anywhere else.
FWIW, I absolutely agree with Joel insofar as C++ coding is concerned. Exceptions are godawful in C++, particularly if you're doing a lot of COM programming, and return codes are 100% the way to go. Exceptions and COM DO NOT MIX.
But in C# I can't live without exceptions and I wouldn't want to, and I don't want to go back.
Eric Lippert | 2003.10.14 11:55 PM
After reading your post earlier today, I re-read Mr. Spolsky's comments and realized that they were in fact confined to "both Java and C++". Having overlooked this, I (and apparently others) have probably interpreted his remarks more broadly than he may have intended.
Nothing like an "xxxx is worse than goto's" statement to really raise a ruckus, especially from someone whose opinion we all respect so much.
One thing's clear, I've got to stop blogging after midnight.
ewbi.develops | 2003.10.15 05:11 PM
TrackBack URL: http://www.typepad.com/services/trackback/6a00d8341c7bd453ef00d83420326b53ef
Listed below are links to weblogs that reference Joel Spolsky in Error:
» Exceptions are for exceptional situations from /* Rambling comments... */
Like drumming up traffic to your site, perhaps? ;) On Monday Joel Spolsky wrote a controversial piece about exceptions; he hates them. [Read More]
Tracked on Oct 15, 2003 12:29:18 AM