Program logic bugs vs input/environmental errors
Steven Schveighoffer via Digitalmars-d
digitalmars-d at puremagic.com
Tue Sep 30 05:43:37 PDT 2014
On 9/29/14 3:44 PM, Jeremy Powers via Digitalmars-d wrote:
> On Mon, Sep 29, 2014 at 12:28 PM, Sean Kelly via Digitalmars-d
> <digitalmars-d at puremagic.com <mailto:digitalmars-d at puremagic.com>> wrote:
>
> Checked exceptions are good in theory but they failed utterly in
> Java. I'm not interested in seeing them in D.
>
>
> I've heard this before, but have not seen a reasonable argument as to
> why they are a failure. Last time this was discussed a link to a blog
> was provided, with lots of discussion there - which as far as I could
> tell boiled down to 'catching exceptions is ugly, and people just do the
> wrong thing anyway which is ugly when you have checked exceptions.'
>
> I am unlucky enough to write Java all day, and from my standpoint
> checked exceptions are a huge win. There are certain edges which can
> catch you, but they are immensely useful in developing robust programs.
> Basically checked exceptions -> recoverable problems, unchecked ->
> unrecoverable/programming errors (like asserts or memory errors).
Well, the failure comes from the effort to effect a certain behavior.
Sun was looking to make programmers more diligent about handling errors.
However, humans are lazy worthless creatures. What ends up happening is,
the compiler complains they aren't handling an exception. They can't see
any reason why the exception would occur, so they simply catch and
ignore it to shut the compiler up.
In 90% of cases, they are right -- the exception will not occur. But
because they have been "trained" to simply discard exceptions, it ends
up defeating the purpose for the 10% of the time that they are wrong.
If you have been able to resist that temptation and handle every
exception, then I think you are in the minority. But I have no evidence
to back this up, it's just a belief.
> Note I am not advocating adding checked exceptions to D (though I would
> like it). Point is to acknowledge that there are different kinds of
> exceptions, and an exception for one part of the code may not be a
> problem for the bit that invokes it.
>
I think this is appropriate for a lint tool for those out there like
yourself who want that information. But requiring checked exceptions is
I think a futile attempt to outlaw natural human behavior.
-Steve
More information about the Digitalmars-d
mailing list