| ▲ | fn-mote 3 hours ago | ||||||||||||||||||||||
The author says "Rust crashes all of the time" and then goes on to invoke the Cloudflare unwrap() as an example of that. Uhhhh... but that was clearly a programmer error, right? Ignoring the possibility of a Result being Err instead of Ok is not something the language is supposed to protect you against. | |||||||||||||||||||||||
| ▲ | tialaramex 29 minutes ago | parent | next [-] | ||||||||||||||||||||||
By coincidence I was talking to one of Cloudflare's engineers this weekend† and they actually argued that the unwrap() isn't the problem per se, that instead it's just wrong to go from "We don't know if this data works" to "Everything is broken" without the step where you check that data works - and that's still true if we're doing this once per minute not once per month. I argued that requiring expect("expectation") calls rather than unwrap() instils the discipline to consider what you're expecting and thus why you think we won't panic - to write the text in the expect call, but I did not convince them and they remained sure that what Cloudflare needs is better deployment discipline not improved engineering practices. † It is a coincidence that they work for Cloudflare, it was quite intentional that I spent much of my weekend with them, we were playing video games. | |||||||||||||||||||||||
| ▲ | loeg 3 hours ago | parent | prev | next [-] | ||||||||||||||||||||||
Yes, but in C++ we would simply not have asserted the result has_value instead of has_error and instead returned some implicit memory corruption. Or, I think that is the author's argument. (I don't subscribe to that point of view.) | |||||||||||||||||||||||
| |||||||||||||||||||||||
| ▲ | byko3y 3 hours ago | parent | prev [-] | ||||||||||||||||||||||
There are programming languages/models/runtimes that crash and recover, there are models that gracefully degrade. Rust cannot recover. Neither can C++ in many cases e.g. when you have an exception in a destructor then it's a guaranteed `std::terminate`. Do note that C did not have such a flaw built into language — C++ authors invented it and Rust inherited this flaw (the authors simply did not feel like it's a flaw). I mean specially designed embedded C code can survive total RAM erasure and still perform some meaningful work (with CPU registers and ROM intact). Or compare it to BEAM that can have processes crash all day long and still continue to work. "Memory safety at all cost" is not a practical requirement — it's theological. | |||||||||||||||||||||||
| |||||||||||||||||||||||