News for hackers. Stuff that matters.
Re:Go is still not good by empath75 on Friday August 22, 2025 @12:00PM (#44986175)
> It's never been clear to me where such a type is actually useful. In what cases do you really need to restrict it to valid UTF-8?

Because 99.999% of the time you want it to be valid and would like an error if it isn't? If you want to work with invalid UTF-8, that should be a deliberate choice.

Re:Go is still not good by maxdamantus on Friday August 22, 2025 @12:34PM (#44986578)
Do you want grep to crash when your text file turned out to have a partially written character in it? 99.999% seems very high, and you haven't given an actual use case for the restriction.
Re:Go is still not good by gf000 on Friday August 22, 2025 @01:26PM (#44987210)
Crash? No. But I can safely handle the error where it happens, because the language actually helps me with this situation by returning a proper Result type. So I have to explicitly check which "variant" I have, instead of forgetting to call the validate function in case of go.
Re:Go is still not good by empath75 on Friday August 22, 2025 @01:28PM (#44987236)
Rust doesn't crash when it gets an error unless you tell it to. You make a choice how to handle the error because you have to it or it won't compile. If you don't care about losing information when reading a file, you can use the lossy function that gracefully handles invalid bytes.