Re:Experience report on a large Python-to-Go translation
by gameswithgo on Wednesday February 12, 2020 @07:58AM
(#22308409)
> if ESR had converted to Rust instead,
Rust would have solved three of his complaints with Go: Sum types, iterators, and generics.
Borrow checking can get especially tricky with graph algorithms though, so perhaps that would have been a new issue.
Re:Experience report on a large Python-to-Go translation
by xvilka on Wednesday February 12, 2020 @08:35AM
(#22308659)
For graph algorithms there is a good Petgraph[1][2] crate, so many common operations can be done in no time.
Re:Experience report on a large Python-to-Go translation
by devmop on Wednesday February 12, 2020 @07:10AM
(#22308157)
It's ugly either way but for clarity you can move the error checks into the transformation leaving the call point clean.
i.e transform1 returns (result, error) and transform2 accepts (result, error) and short-circuits if err is not nil.
It allows the expressive and succinct description of a transformation list but with a bunch of messiness hidden.
Re:Experience report on a large Python-to-Go translation
by andrewzah on Wednesday February 12, 2020 @04:03PM
(#22312789)
This isn't ideal, because it forces each successive function that takes a Result type to add handling code in the case of an error.
fn(fn(fn()?)?)? is a bit gnarly but better than duplicate code like that, imo.
Re:Experience report on a large Python-to-Go translation
by kofejnik on Wednesday February 12, 2020 @10:23AM
(#22309487)
something something Maybe monad
Re:Experience report on a large Python-to-Go translation
by pk2200 on Wednesday February 12, 2020 @10:29PM
(#22315098)
He evaluated Rust and Go a few years ago and strongly preferred Go.
Re:Experience report on a large Python-to-Go translation
by ASalazarMX on Wednesday February 12, 2020 @01:54PM
(#22311582)
the final ")?)?)?" is kinda unsettling, but I can't explain why.
Re:Experience report on a large Python-to-Go translation
by steveklabnik on Wednesday February 12, 2020 @10:28AM
(#22309546)
ESR tried Rust a while back, and decided to go with Go in general.
The original Python code using exceptions was:
Making that use error return values looks quite verbose in Go, but Rust has syntax specifically for that case, making it quite manageable: