News for hackers. Stuff that matters.
Re:From Rust to TypeScript by flowerlad on Saturday September 12, 2020 @12:09PM (#24453459)
> "oh shit, that throws" whackamole

You don't have that problem in languages that support checked exceptions.

Re:From Rust to TypeScript by ufmace on Saturday September 12, 2020 @01:22PM (#24453929)
I've never seen a language that supported checked exceptions and actually used them consistently for everything.

But then that would be kind of awful, because IMO the checked exceptions cases for "I know this will never actually throw, leave me alone" and "This is just a quick script, go ahead and blow up the whole program if this fails" are poor, forcing you to write try catch blocks all over the place.

IMO, Rust has a nice approach for being stricter - unwrap. If it's a quick script, throw unwrap everywhere with reckless abandon. For real programs, grep for unwrap and make sure for every one, you really know for sure that it will never fail or that blowing up the whole program if it does is the right move. To convert from one to the other, grep unwrap and actually think about what you want to happen if that line is Err.

Re:From Rust to TypeScript by kibwen on Saturday September 12, 2020 @12:51PM (#24453719)
You may still have that problem if the language also supports unchecked exceptions.
Re:From Rust to TypeScript by dilap on Saturday September 12, 2020 @12:15PM (#24453498)
Agreed, mostly true.

(It's still not as explicit about where your function might exit, but you won't get surprise exceptions, which is way nicer.)

Re:From Rust to TypeScript by dehrmann on Saturday September 12, 2020 @02:25PM (#24454342)
You do and you don't. If you're using a Java library written by someone who doesn't believe in checked exceptions in Java, you might be lulled into thinking everything will be fine.