|
|
|
Advertisement
|
Anders Hejlsberg: The scalability issue is somewhat related
to the versionability issue. In the
small, checked exceptions are very enticing. With a little example, you can show
that you've actually checked that you caught the
FileNotFoundException, and isn't that great? Well, that's fine
when you're just calling one API. The trouble begins when you start building big
systems where you're talking to four or five different subsystems. Each
subsystem throws four to ten exceptions. Now, each time you walk up the
ladder of aggregation, you have this exponential hierarchy below you of
exceptions you have to deal with. You end up having to declare 40 exceptions
that you might throw. And once you aggregate that with another subsystem you've got
80 exceptions in your throws clause. It just balloons out of control.
In the large, checked exceptions become such an irritation that people
completely circumvent the feature. They either say, "throws
Exception," everywhere; or—and I can't tell you how many times I've
seen this—they say, "try, da da da da da, catch curly curly." They
think, "Oh I'll come back and deal with these empty catch clauses later," and then of
course they never do. In those situations, checked exceptions have actually degraded the
quality of the system in the large.
And so, when you take all of these issues, to
me it just seems more thinking is needed before we put some kind of checked
exceptions mechanism in place for C#.
But that said, there's certainly tremendous value in knowing what exceptions
can get thrown, and having some sort of tool that checks. I don't think we can
construct hard and fast rules down to, it is either a compiler error or not. But I
think we can certainly do a lot with analysis tools that detect suspicious code,
including uncaught exceptions, and points out those potential holes to you.
Come back Monday, September 1 for part VII of a conversation with Elliotte Rusty Harold about the design of the XOM API. I am now staggering the publication of several interviews at once, to give the reader variety. The next installment of this interview with Anders Hejlsberg will appear on Monday, September 8. If you'd like to receive a brief weekly email announcing new articles at Artima.com, please subscribe to the Artima Newsletter.
Have an opinion about the design principles presented in this article?
Discuss this article in the News & Ideas Forum topic,
The Trouble with Checked Exceptions.
Resources
Deep Inside C#: An Interview with Microsoft Chief Architect Anders Hejlsberg:
http://windows.oreilly.com/news/hejlsberg_0800.html
A Comparative Overview of C#:
http://genamics.com/developer/csharp_comparative.htm
Microsoft Visual C#:
http://msdn.microsoft.com/vcsharp/
Anders Hejlsberg was not the first Artima interviewee to mention taste. Jim Waldo made almost
an identical comment about building a team of tasteful programmers in his interview:
http://www.artima.com/intv/waldo10.html
And an entire portion of Ken Arnold's interview was devoted to design taste - Taste and Aesthetics:
http://www.artima.com/intv/taste.html
|
Sponsored Links
|