News for hackers. Stuff that matters.
Re:My Struggles with Rust by vbezhenar on Sunday May 07, 2017 @09:18AM (#14285310)
Implicit return codes (e.g. return int, -1 means error, 0+ means OK) are equivalent to unchecked exceptions. Explicit return codes, where you must process them or compiler will yell at you are equivalent to checked exceptions. I think, that checked exceptions are a good idea, but they must be improved. E.g. Rust have syntax for almost implicit converting one error to another and return it; checked exceptions could use similar approach, so you can declare another exception in your "throws" cause and compiler'll generate conversion code for any unhandled checked exception.

Anyway for me exceptions are way easier to work with, than return codes.

Re:My Struggles with Rust by jimktrains2 on Sunday May 07, 2017 @09:44AM (#14285418)
Yes, exceptions are better than return codes, but I would argue Result types are better than exceptions. Checked exceptions in Java have their issues. Exceptions in C++ are odd beasts (though that's getting better, they're still not checked and therefor basically anything that isn't noexcept can throw them (oh wait! noexcept can throw! it just crashes immediately)).
Re:My Struggles with Rust by quicknir on Sunday May 07, 2017 @09:03PM (#14288586)
That equivalence is false. An unhandled exception bubbles up. An unhandled return code is ignored. This was exactly one of the biggest arguments against return codes.