May 27, 2020 Re: What's the best way to find out which exceptions may be thrown ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Wednesday, 27 May 2020 at 11:40:00 UTC, Mike Parker wrote:
> On Wednesday, 27 May 2020 at 10:30:36 UTC, wjoe wrote:
>> On Wednesday, 27 May 2020 at 10:01:33 UTC, Mike Parker wrote:
>> Could you please elaborate why checked exceptions are more annoying?
>>
>
> For me, it's because they require all functions that touch them to either try/catch or include an exception specification in its declaration. In my Java days, I ended up just doing what so many others do and adding `throws Exception` or `catch(Exception)` to avoid having to handle multiple exception types. Most of the time, I didn't care what specific sort of exception was thrown.
Johannes, Dennis, Mike that was very insightful. I didn't consider those reasons.
Thank you very much for the elaboration :)
|
June 02, 2020 Re: What's the best way to find out which exceptions may be thrown ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Mike Parker | On Wednesday, 27 May 2020 at 11:40:00 UTC, Mike Parker wrote: > On Wednesday, 27 May 2020 at 10:30:36 UTC, wjoe wrote: >> On Wednesday, 27 May 2020 at 10:01:33 UTC, Mike Parker wrote: >> Could you please elaborate why checked exceptions are more annoying? >> > > For me, it's because they require all functions that touch them to either try/catch or include an exception specification in its declaration. In my Java days, I ended up just doing what so many others do and adding `throws Exception` or `catch(Exception)` to avoid having to handle multiple exception types. Most of the time, I didn't care what specific sort of exception was thrown. Because of the problems with checked exceptions they were deliberately left out in C#. Here is an interview with Anders Hejlsberg, the creator of C# at MS, where he explains the reasons for this decision: https://www.artima.com/intv/handcuffs.html |
June 03, 2020 Re: What's the best way to find out which exceptions may be thrown ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bienlein | On Tuesday, 2 June 2020 at 13:58:13 UTC, Bienlein wrote:
> Because of the problems with checked exceptions they were deliberately left out in C#. Here is an interview with Anders Hejlsberg, the creator of C# at MS, where he explains the reasons for this decision: https://www.artima.com/intv/handcuffs.html
This wouldn't seem to apply if checked exceptions were inferred by default, right? And the issues with Java generics don't apply to D, because our metaprogramming infers attributes anyways.
|
June 03, 2020 Re: What's the best way to find out which exceptions may be thrown ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to wjoe | On Wednesday, 27 May 2020 at 10:30:36 UTC, wjoe wrote:
>
> Could you please elaborate why checked exceptions are more annoying?
>
Have like 3 functions : A calls B, B calls C .
Imagine that now you need to throw a checked exception on C, that before wasn't necessary.
You need to add the annoying "throws X" to A and B. And A and B could be on another module or on a different project. Perhaps, the guy that wrote B, was previsor, and putted "throws Exception" (or another generic Exception derived class) on B to avoid problems, but now you have loss the information about the specific Exception that C throws. So again, the compiler can't know what kind of exception could be throwed by A beyond of a generic "Exception" (or another generic exception class). Another workaround, could be wrapping the C throwed exception by a generic exception on B.
I work daily with Java, and it's pretty annoying. That the IDE helps you auto putting the throws or suggesting a try/catch, helps. But we ended making some generic exceptions RuntimeExceptions to avoiding the noise and problems that could give checked exceptions.
|
June 03, 2020 Re: What's the best way to find out which exceptions may be thrown ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Bienlein | On Tuesday, 2 June 2020 at 13:58:13 UTC, Bienlein wrote:
> On Wednesday, 27 May 2020 at 11:40:00 UTC, Mike Parker wrote:
>> On Wednesday, 27 May 2020 at 10:30:36 UTC, wjoe wrote:
>>>[...]
>>
>> For me, it's because they require all functions that touch them to either try/catch or include an exception specification in its declaration. In my Java days, I ended up just doing what so many others do and adding `throws Exception` or `catch(Exception)` to avoid having to handle multiple exception types. Most of the time, I didn't care what specific sort of exception was thrown.
>
> Because of the problems with checked exceptions they were deliberately left out in C#. Here is an interview with Anders Hejlsberg, the creator of C# at MS, where he explains the reasons for this decision: https://www.artima.com/intv/handcuffs.html
That was a good read. Thank you.
|
June 03, 2020 Re: What's the best way to find out which exceptions may be thrown ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Luis | On Wednesday, 3 June 2020 at 07:19:45 UTC, Luis wrote:
> On Wednesday, 27 May 2020 at 10:30:36 UTC, wjoe wrote:
>>
>> Could you please elaborate why checked exceptions are more annoying?
>>
>
>
> Have like 3 functions : A calls B, B calls C .
> [...]
>
> I work daily with Java, and it's pretty annoying. That the IDE helps you auto putting the throws or suggesting a try/catch, helps. But we ended making some generic exceptions RuntimeExceptions to avoiding the noise and problems that could give checked exceptions.
I was thinking about IDE assistance, too, but after reading the interview with Anders Hejlsberg mentioning the ballooning problem - I can see how checked exceptions can get out of control.
|
Copyright © 1999-2021 by the D Language Foundation