News for hackers. Stuff that matters.
Re:Dark side of ergonomics in Rust by heavenlyhash on Saturday April 14, 2018 @06:17AM (#16836724)
> For exceptions to work predictably, all mutation within a try-catch block should be captured in a transaction that can be rolled back.

Wouldn't that just be beautiful?

Re:Dark side of ergonomics in Rust by the_grue on Saturday April 14, 2018 @08:14AM (#16837005)
That sounds like a natural fit for Rust's lifetime-tracking mechanism. The compiler can automatically drop all initialized objects upon exception. In fact, I'm reasonably sure it does just that for panic handling.
Re:Dark side of ergonomics in Rust by panic on Saturday April 14, 2018 @08:34AM (#16837043)
That example is initialization code, but you'd run into the same problem even if the control were already initialized (and you were trying to set new properties on it). In that case, you'd likely have a borrowed pointer, so it wouldn't be dropped when the panic happened.
Re:Dark side of ergonomics in Rust by ordu on Saturday April 14, 2018 @09:40AM (#16837274)
The pointer can be dropped. The pointed object cannot. So the problem of rolling back the transaction changes ownership, now our button should do sensible things in setLabel, to rollback changes made before an exception.
Re:Dark side of ergonomics in Rust by ben0x539 on Saturday April 14, 2018 @10:02AM (#16837344)
imo the dream of exceptions is deferring error handling so happy-path code can be straightforward and free of worries, but if every line of code indirectly under a try-catch block has to embody transactional thinking to enable proper RAII behavior, that seems like a huge obligation.
Re:Dark side of ergonomics in Rust by emn13 on Saturday April 14, 2018 @01:10PM (#16838244)
So, that's the bad-stuff perspective. But transactions in actual DB's show it doesn't have to be that way, and transaction isolation is likely to be easier in a language than a DB because you typically communicate via a fairly narrow, well-defined channel, and not via a morass of side-effects.

Another good-stuff perspective are processes or equivalents (e.g. erlang's internal processes or docker containers). Happy-path code can ignore errors; sufficiently serious errors tear down the "process" and the calling code can decide how to deal with that (ideally without cleanup responsibilities).

As long as indirect effects are well-contained, there's nothing necessarily wrong with ignoring errors. Especially when fine-grained error handling simply isn't interesting, it can be a relief simply to ignore errors. E.g. DB style fine-grained locking is really only possible because you don't need to manually deal with each and every possible failure moment (because there are unbelievably many).

Re:Dark side of ergonomics in Rust by ben0x539 on Sunday April 15, 2018 @08:37AM (#16842406)
yeah i agree that seems like a generally desirable state of affairs.

not sure if i'd sign the statement "you typically communicate via a fairly narrow, well-defined channel, and not via a morass of side-effects" though ;)

Re:Dark side of ergonomics in Rust by emn13 on Sunday April 15, 2018 @02:26PM (#16844073)
Hey, it's aspirational ;-).
Re:Dark side of ergonomics in Rust by anacrolix on Saturday April 14, 2018 @10:24AM (#16837425)
Haskell's STM monad.