3 ms·
>> What have been the main lessons from your C to Rust migration? Biggest takeaways: Rust's ownership rules enforce "multiple readers, one writer" patterns so
by thesuperbigfrog 3y ago
>> What have been the main lessons from your C to Rust migration?
Biggest takeaways:
Rust's ownership rules enforce "multiple readers, one writer" patterns so plan for such patterns in your design.
Embrace Rust's Result and Option types for error-handling and design. They are elegant and powerful when used with 'match'.
Unit tests right next to the code they test is a huge win. Doc-tests and 'cargo doc' is literate programming (https://en.wikipedia.org/wiki/Literate_programming https://en.wikipedia.org/wiki/Literate_programming).
The phf crate (https://docs.rs/phf/latest/phf/ https://docs.rs/phf/latest/phf/) is awesome for global constant data tables.
>> Was there anything that surprised you?
Our Rust code is much more concise than the previous C code. It takes about three times as much C code versus Rust code, but the C code feels much more brittle and less portable.
- justincredible 3y ago[dead]