News for hackers. Stuff that matters.
Re:All Programming Languages are Wrong (2018) by erik_seaberg on Wednesday February 12, 2020 @02:57AM (#22306825)

  stream.map(f).collect(…)
is where checked exceptions failed. #map is a generic method that should obviously throw each of the checked exceptions f can throw, but without some kind of generic sum type Java can't express that. Everyone is forced to choose between "can throw any exception" (e.g., Callable<T>) and "can only throw unchecked exceptions" (e.g., Function<T, U>), each of which spreads virally and punishes anyone using specific throws clauses.
Re:All Programming Languages are Wrong (2018) by lokedhs on Wednesday February 12, 2020 @03:16AM (#22306916)
There is no need to get rid of checked exceptions to fix that.

You need generics for exceptions. If the inner function can throw some exception, then it should be possible to declare the stream method that it will throw the same exception.

I believe that the JVM doesn't actually support this, so the reasons were got the horrible situation we're in is because they didn't want to sacrifice backward compatibility.

Re:All Programming Languages are Wrong (2018) by erik_seaberg on Wednesday February 12, 2020 @03:41AM (#22307056)
I think we're saying the same thing. If f(T) can return U or throw A or B or C, there needs to be a way to declare that Stream<T>#map takes a Function<T, U, A|B|C> and returns a Stream<U> or throws A or B or C. But that sum type A|B|C doesn't exist in Java if there's no common base class.