4 ms·
I wonder how hard it would be to create a C -> Rust transpiler. The output would probably be God-awful, but it could be a start to moving away from C towards Ru
by wspeirs 11y ago
I wonder how hard it would be to create a C -> Rust transpiler. The output would probably be God-awful, but it could be a start to moving away from C towards Rust.
- steveklabnik 11y agoYes, the problem with doing this is that Rust really imposes certain kinds of design constraints that makes this hard. Like, you COULD, but you'd make a lot of use of unsafe, in a way that's not idiomatic. Part of the problem here is that the program may rely on subtleties that make the translation hard. I've seen experienced C or C++ people come into the Rust IRC and ask why certain things aren't allowed, it's often due their code relying on certain aspects of the looser model. That said, it's very possible to go unsafe first and then refactor. It just might not be easy. Another way of making the transition is to pick a component and only re-write it. This is the approach Firefox is taking, for example.
- mcguire 11y agoA guess: very, very difficult. Writing code to satisfy Rust's checking is not much harder than writing C[1], but converting arbitrary C to satisfy Rust is something completely different. [1] An' I say it as shouldn't. C is my natural language.