Checked vs unchecked exceptions
mckoder via Digitalmars-d
digitalmars-d at puremagic.com
Tue Jun 27 03:18:04 PDT 2017
On Tuesday, 27 June 2017 at 06:10:52 UTC, Tobias Müller wrote:
>
> It's not at all bad code to write things down that the compiler
> could infer, quite the opposite.
> Writing it down signals _intent_ and the compiler can check if
> the implementation is matching the specification which gives
> you additional security.
> Additionally it allowes the compiler to do the checks locally
> which is much easier.
>
> Function signatures are interfaces which should be
> self-contained IMO, i.e. it should not be necessary to examine
> the function body. That's what signatures are for. At very
> least for public interfaces.
>
> I honestly don't understand how people that care a great deal
> about expressive type systems can be so opposed to checked
> exceptions. After all they wouldn't use 'object' for everything
> either.
>
Bravo! These are very important points!
FWIW, Bruce Eckel who is so often quoted by people who are
opposed to checked exceptions comes from a dynamic language
background. Here's a relevant quote by Bruce Eckel:
"I think that the belief that everything needs strong static
(compile-time) checking is an illusion; it seems like it will buy
you more than it actually does. But this is a hard thing to see
if you are coming from a statically-typed language."
Source:
https://groups.google.com/forum/#!original/comp.lang.java.advocacy/r8VPk4deYDI/qqhL8g1uvf8J
If you like dynamic languages such as Python you probably agree
with Bruce Eckel. If you are a fan of static checking then I
don't see how you can like that.
More information about the Digitalmars-d
mailing list