3 ms·
I think you would probably catch a bunch of safety issues rewriting any code. As well as introduce new ones.
by ryanmarsh 8y ago
I think you would probably catch a bunch of safety issues rewriting any code.
As well as introduce new ones.
- kevincox 8y agoOf course. I would suspect that with Rust you would introduce less new ones but I just wanted to point out that finding bugs isn't evidence that the language helped you out. Even though I am a believer I would love to see some solid evidence of Rust making code safer.
- derefr 8y agoThat's only if you rewrite "from the design" in a fresh repo. If, on the other hand, you rewrite the code line by line from C to Rust (which Rust is actually quite amenable to!), faithfully translating the semantics of the C code into the Rust code (and thereby having to use lots of unsafe{} blocks) then you can avoid most of the problems—what you'll end up with will essentially be the same as what a hypothetical C-to-Rust transpiler would output. Importantly, you can also translate the test suite in this same way. After that step is done, you can just refactor the resulting code, replacing unsafe{} blocks with Rust idioms, and then rerunning the tests (which you can leave un-idiomatized) as regression tests.