How to rewrite it in Rust
adventures.michaelfbryan.com
How to rewrite it in Rust
1–10 of 43 posts
Re: How to rewrite it in Rust
#2You don't actually have to rewrite everything on day one. You can stop writing new C code right now, and then gradually replace old code only when you need to fix it or refactor it.
Re: How to rewrite it in Rust
#3Re: How to rewrite it in Rust
#4Re: How to rewrite it in Rust
#5Great guide, this looked surprisingly straightforward.
Re: How to rewrite it in Rust
#6This ability to incrementally add Rust to a C codebase is very useful for adopting Rust in established projects. You don't actually have to rewrite everything on day one. You can stop writing new C code right now, and then gradually replace old code only when you need to fix it or refactor it.
The big difference is however that JS and TS can live side by side on a file by file basis out of the box with the Typescript compiler, which makes it super easy to convert. You don't have this luxury with C and Rust of of the box, but serious kudos to the author for finding a way to do something very similar.
When converting C to Rust you usually have to do things on a module by module or compile artifact by compile artifact basis, which makes it much more challenging. You can however employ some sort of strangler pattern: https://docs.microsoft.com/en-us/azure/architecture/patterns...
Re: How to rewrite it in Rust
#7This ability to incrementally add Rust to a C codebase is very useful for adopting Rust in established projects. You don't actually have to rewrite everything on day one. You can stop writing new C code right now, and then gradually replace old code only when you need to fix it or refactor it.
Twice I've been part of a move from Javascript to Typescript that worked much the same. Both projects were large applications with several developers working on them. Both had been ongoing for a few years before the port started. In both projects we decided to write all new code in Typescript and convert JS to TS when we made any largish change to an existing JS file. In both cases it took around a year for us to hit…
OP is essentially about proving the opposite. It does take a bit of setup to get there, but you can ultimately translate C to Rust on a function-by-function basis, and Rustify interfaces, data structures, etc. only gradually after nothing on the C side is relying on the older defs.
C++ would be more of a challenge - you need to forgo quite a few C++-exclusive features to end up with interfaces that Rust can work with. That's where an "artifact by artifact" approach might work better. Other languages would be roughly similar, with their heavyweight C FFI's.
Re: How to rewrite it in Rust
#8Earlier quoted context omitted.
Twice I've been part of a move from Javascript to Typescript that worked much the same. Both projects were large applications with several developers working on them. Both had been ongoing for a few years before the port started. In both projects we decided to write all new code in Typescript and convert JS to TS when we made any largish change to an existing JS file. In both cases it took around a year for us to hit…
> When converting C to Rust you have to do things on a module by module or compile artifact by compile artifact basis, which makes it much more challenging. OP is essentially about proving the opposite. It does take a bit of setup to get there, but you can ultimately translate C to Rust on a function-by-function basis, and Rustify interfaces, data structures, etc. only gradually after nothing on the C side is relying…
Re: How to rewrite it in Rust
#9By rewriting small components and integrating them into the existing project using Javas native interface, our small team of 5 developers were able to pull off this massive rewrite in just under a year. The resulting code base is rearchitected in a few very important ways, but mostly follows the same structure.
And because we kept and evolved our old Scala based test suite, we have a very high confidence in the rewrite.
When Async/.await finally landed, we could switch over very quickly, and it has been a joy to focus on benchmarks and performance over the last month. Spoiler: Rust is faster than Scala :-D
Re: How to rewrite it in Rust
#10We did a similar thing with a Scala -> Rust rewrite for the http://prisma.io query engine. By rewriting small components and integrating them into the existing project using Javas native interface, our small team of 5 developers were able to pull off this massive rewrite in just under a year. The resulting code base is rearchitected in a few very important ways, but mostly follows the same structure. And because we k…
Huge shoutout to everyone working on Rust Async, especially the Berlin crew, who has been very helpful.