Re:Translating Quake 3 into Rust
by smolder on Tuesday January 07, 2020 @11:00AM
(#21981162)
The long tail of patterns c2rust would need to recognize to reliably make idiomatic code seems like a much larger problem. With that as the goal, it might make sense to build a separate rust-to-rust "idiomaticizer" that can recognize opportunities to reduce code complexity through refactoring, and apply idiomatic patterns without changing application behavior.
[ Parent
| on HN ]
Re:Translating Quake 3 into Rust
by harpocrates on Tuesday January 07, 2020 @12:05PM
(#21981892)
As I've already posted elsewhere on this thread, such a tool has been developed in parallel (and with the intent to consume the output of) c2rust. Development on that occurs here: https://github.com/immunant/c2rust/tree/master/c2rust-refact....
Thanks, I hadn't seen this by the time I posted. Very cool.
Re:Translating Quake 3 into Rust
by bluejekyll on Tuesday January 07, 2020 @11:43AM
(#21981625)
Maybe. Though there might be lowish hanging fruit that could potentially recognize arrays that could be translated to slices, and heap based allocations using pointer traversal that could be converted to Vec instead.
The real issue with doing that isn’t imo, going to Rust, it’s understanding what still needs to be addressable in C. For example, a self-contained application has no external ABI dependencies, and so could assume everything that references that slice must only need to be Rust. A library on the other-hand might still need to present a C ABI.
Re:Translating Quake 3 into Rust
by PudgePacket on Tuesday January 07, 2020 @11:38AM
(#21981562)
Clippy already sort is is that, though it seems to target smaller scope idiomatic changes.
It's a much harder problem for a tool to recognise the design patterns C pushes you towards and refactor that to something more native to Rust.