Re:Why Rust helps even if you have to use a lot of `unsafe`
by TillE on Wednesday August 02, 2023 @11:18AM
(#36972076)
That's just std::optional<> vs std::string, isn't it?
[ Parent
| on HN ]
Re:Why Rust helps even if you have to use a lot of `unsafe`
by fnfjfk on Wednesday August 02, 2023 @11:42AM
(#36972435)
Yes, and std::optional is a janky implementation of a sum type in a language that doesn’t have them. The ergonomics are bad, and it is easy to make your program blow up if you forget a check.
In a language with sum types like Rust, Kotlin, and Swift, if you’re following the default “happy path” of coding, you are not allowed to forget a check. The compiler will not let you.