News for hackers. Stuff that matters.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by hedora on Thursday July 13, 2023 @09:49PM (#36718481)
Checked (and unchecked) exceptions create an exponential number of control flow paths. Consider:

   try {
      throws_a();
      r = grab_resource();
      throws_b();
      r.throws_a();
   } catch (a) {
      r.release(); // oops; null pointer some times
   } catch (b) {
      try {
        r.release();
      } catch (a) {
        // nooo....
      } 
   } finally {
     if r != null {
        r.finalize() // use after release (sometimes)
        r.release() // ???
     } 
   }
There is plenty of academic literature showing that real programs are even worse than my contrived example, on average.
Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by josefx on Friday July 14, 2023 @02:27AM (#36720169)
> r.release(); // oops; null pointer some times

Quite sure Java would prevent that if r was never assigned.

Also most languages provide cleaner try-with-resources or RAII style lifetime management so you don't actually end up with that kind of spaghetti code unless you actively go out of your way to be bad at programming.

Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by masklinn on Friday July 14, 2023 @10:49AM (#36724797)
> Also most languages provide cleaner try-with-resources or RAII style lifetime management so you don't actually end up with that kind of spaghetti code unless you actively go out of your way to be bad at programming.

Context managers (try with resources) specifically don't work at all when release is conditional e.g. open a file, need some post processing, need to close the file if the post-processing fails but return it if it succeeds.

Defers don't either, unless you have a specialised one (e.g. zig's errdefer).

Actual RAII (aka affine types) does work, but adding that to a GC'd langage after the fact is a huge undertaking and increase in complexity, because the interaction between affine and normal types is fraught.

Re:Unchecked Java: Say Goodbye to Checked Exceptions Forever by Supermancho on Saturday July 15, 2023 @12:54PM (#36738748)
The construction of arbitrary convolutions of logic is not demonstrative of your assertions. A multitude of code paths is not specific to checked exceptions. Note: It is possible to try catch a union of exception types in the recent versions of Java (catch X | Y | Z).

The paths are still there if the exceptions are all unchecked or combined or not using exceptions at all. Passing exceptions up is rarely the right choice, imo. If it's a terminal runtime, sure, obv.