News for hackers. Stuff that matters.
Re:New Features in Java 14 by aw1621107 on Tuesday March 03, 2020 @07:02PM (#22479982)
Rust does in fact have a ? operator [0], but it works slightly differently than Kotlin's in that it returns early if a None/Result<Err> is encountered instead of just resolving to that None/Result<Err>. If that isn't what you want, then Option::map() is a fine substitute.

[0]: https://doc.rust-lang.org/edition-guide/rust-2018/error-hand...

Re:New Features in Java 14 by benibela on Wednesday March 04, 2020 @05:04PM (#22488653)
But there is still a function that panics.

Java has solved memory safety. Now the task is to make sure that code that can panic will not compile

Re:New Features in Java 14 by aw1621107 on Wednesday March 04, 2020 @05:38PM (#22488930)
The function that can panic still exists, but the ? operator itself won't invoke a panic. Sort of like how you can still get NullPointerExceptions in Kotlin using !!, but standard practice is to use a safer option.

Exception/panic-free code is fairly straightforward; you just need to have APIs return Option<_>/Result<_>/other error code equivalents to indicate failure. The problem with that is that it introduces some amount of friction that will probably make some programmers unhappy.

If you want to avoid returning Option<_>/Result<_>/other error code equivalents, you need some way to prove your inputs cannot trigger an invalid result, and that is a very difficult problem.