Has anyone here tried migrating a C++ codebase to Rust? I'm curious about how you dealt with subtle changes in behavior during the migration.
I've been experimenting with C++ to safe Rust translation lately, and the more I work on it, the more I feel like syntax is the easy part. Things like undefined behavior, integer overflow, and iteration order are much more interesting (and painful), especially when the translated code compiles and runs but gives slightly different results.
One approach I've been experimenting with is making those decisions explicit instead of letting the translator silently choose what to do. The developer makes the decision, and the translator keeps a record of it.
I tried this on ROOT's Minuit2 (~14k lines of C++), and all 13 numerical tests produced byte-for-byte identical output. Performance is pretty terrible right now (17–56x slower for computation), since it still relies on a checked memory model, and only a small part is plain Rust so far.
What I'm wondering is whether preserving behavior this explicitly is actually something people care about in practice.
For those who've done real migrations, was this ever a major concern? Or does incremental migration with FFI make most of this unnecessary?
I'm also curious about what kinds of problems you've run into that an automated translator probably wouldn't handle well.
11 posts - 7 participants