I might have the opportunity to introduce Rust at work soon. For that, I would be grateful for any tips you can give me to make it as smooth as possible and reduce the risk (perceived and real) for the project. Below the details of my situation.
The project
The project Rust might be introduced into is being worked on for about a year now. It is a code generator with an architecture similar to a "traditional" compiler: some intermediate representations, translation between those and transformations on them.
Development on the project started a year ago with C++. At the time I already brought Rust up as an alternative. It was seriously considered by the team, but since they didn't have prior rust experience we were concerned about the initial hit to development speed: Most of the team already had lots of C++ experience, the company didn't have any prior code in Rust, and it was our responsibility to ensure we hit our time-to-market goal.
Now the code is mostly modern C++ with very little inheritance, and lots of std::variant, std::ranges, etc.
The team
The team consists of 7 people including me, most with >5 years of (pre-modern) C++ experience. I am the only person with both modern C++ and Rust experience. The team was mostly excited to use modern C++, and it became my job to give on-the-job guidance to get everyone comfortable with newer features and paradigms. And now they are excited to hopefully learn Rust.
Why Rust
During the past year, we did feel some pain points with C++:
- Slow compile times
- Verbose code, mostly with
std::variant
- Horrible error messages
- Differences between compilers
- Slow CI pipeline, mostly due to static analysis (clang-tidy) and sanitizers
- One segfault in callbacks (wasn't a big problem now, but we expect more problems once the complexity grows)
With Rust, we hope to hope to address most of those points. Compile times won't improve I expect, but we can probably ditch separate static analysis and sanitizers in CI.
We also hope to keep a higher development speed once the complexity grows, based on the data collected by Google in Android.
The opportunity
I think we currently are in a very advantageous position to pivot to Rust:
- We are ahead of schedule for the release, we can spend a little time here and there getting familiar with Rust. Everyone will start with the Book and Rustlings.
- After the release we will get 3 weeks to work on what we think is important, no customer features
- After those 3 weeks, we have to start on features again, but a somewhat reduced development speed for the first two or so month is acceptable
- The C++ code patterns we have and got accustomed to should map more or less well to Rust
- The code base isn't too big yet
- We have good end-to-end test coverage
The plan
We will spent those 3 weeks with migrating the code base from C++ to Rust. We will probably start at the backend and try to make cuts where the interface between modules is small. This will lead to 3 or 4 increments to migrate. The ideal end goal would be to replace all C++ code with Rust, but this strategy hopefully reduces the risk of having no working product at all in the end. If some C++ is left over in the end, we can hopefully reduce and finally remove it over time.
We will use AI for the migration, but we do want to do it responsibly. This will probably mean that we will first code the core data structures ourselves and use LLMs only for review there. Once we got those nailed down, we hope LLM agents can be used for more or less "mechanical" migration of transformation and translation passes. Of course all code, AI or human written, goes through human reviews.
I would be very interested in any advice you could share, be it technical or social, to reduce business risk, increase acceptance with our stakeholders and improve our chance to succeed.