Canonical is Funding a PhD to Automate C to Rust Translation (itsfoss.com) 41
An anonymous reader shared this report from the blog It's FOSS:
Canonical has committed funding to a three-year PhD project focused on building a system that can automatically translate large C codebases into Rust. And they are not alone; UK Research and Innovation is matching their funding for the project, which is set to run through the University of Bristol's Programming Languages Research Group.
The PhD is aiming to build an all-encompassing platform that can take a C repository running into hundreds of thousands of lines and translate it into Rust that's "safe, behaviourally correct and maintainable Rust."
The work will be carried out by a student, Alex Wood, who will be supported by Professor Meng Wang leading the work, with Dr. Cristina David and Canonical's Jon Seager serving as co-supervisors.
The PhD is aiming to build an all-encompassing platform that can take a C repository running into hundreds of thousands of lines and translate it into Rust that's "safe, behaviourally correct and maintainable Rust."
The work will be carried out by a student, Alex Wood, who will be supported by Professor Meng Wang leading the work, with Dr. Cristina David and Canonical's Jon Seager serving as co-supervisors.
How is that even possible? (Score:5, Insightful)
If the C code does something unsafe, how can it be machine-translated into safe Rust, without knowing the intention of the programmer?
And even is this is possible, what's the point? Why not just make a C compiler that emits "safe" assembler directly? It's not as if a transpiler is likely to emit human-maintainable code.
I know Canonical is all hot for Rust, but this particular project doesn't seem feasible to me.
Re: (Score:3)
You're looking at the problem in a wrong way.
C operations are unsafe and you need to implement safeguards yourself. Sometimes you can implement things rust can't because C allows you unsafe operations, but most programs only implement things that are possible in a safe way, but may fail to guard them (or have secure code that easily becomes insecure when some amateur tries to extend it).
Think of working with a zero terminated string. These operations can easily be translated into every higher level programm
Re: (Score:2)
Hopefully they make significant gains when it comes to maintainability and readability as well. A lot of AI generated code looks superficially properly commented, decent variable names, that sort of thing, but in reality is a pain to deal with and only likely to ever be worked on again by more AI.
Re: (Score:2)
You may need to add something about the style of comments you want to your system prompt. AI defaults to a certain style of comments, which help to understand what a function does and where it related to, but also add "unneeded" documentation about decisions during the development process. I think much of it are signposts for later AI runs, which help AI to quickly understand the feature and where it related to without reading the full code base.
That's also desirable for humans, but the human working with t
Re: (Score:2)
He's not looking at it the wrong way.
You're essentially saying "But a technology that does this would be very valuable!"
Yeah, no shit. So would a technology that turns lead into gold. Or that can tell whether some unwatermarked text is LLM generated or not.
Like both of those cases, it's just not possible. C needs to be translated to Rust by someone who knows the intent of the programmer, as the GP pointed out. Most of the time that's not possible to automate. There are far too many edge cases.
In C a string
Re: (Score:2)
It is perfectly possible to turn lead into gold. The technology has been there for decades. It is simply not economical to do so.
Re: (Score:2, Interesting)
It is not actually possible. Or rather unsafe stuff in C will remain unsafe in Rust. In addition, most/all other bugs (like logic errors, wrong use of system APIs, etc.) in the C code will remain. Rust does not magically make code secure. Coding directly in Rust has some advantages, as it is hard to learn and that keeps the prevalent low-skill coders out. Rust can also avoid some problems (not that many) when the code is designed for Rust. C code is obviously not.
That said, there is an application scenario
Re: (Score:2)
If the resulting Rust code is human-readable and human-maintainable, then yes... I can see wanting to continue in Rust rather than C as a valid use-case.
Re: (Score:1)
So, nobody knows how to code in C anymore is the reason for wanting to transcode all C to Rust?
Re: (Score:2)
So, nobody knows how to code in C anymore is the reason for wanting to transcode all C to Rust?
Not even "nobody" but for some people "a falling number with visibly increasing consulting rates" would be enough.
A CRust Compiler (Score:1)
Re: (Score:2)
My bet is that 99% of C code is easily translatable and doesn't need to do anything unsafe (it may use unsafe methods, but basically in a safe way). If an automatic translator could do that 99% of code and flag the 1% that it cannot handle, that would still be a major time saver in translating it to Rust. This may be a reasonable goal rather than aiming at 100%.
don't get it (Score:3)
Re: (Score:3)
Why not just use the time to make a safe c library of operations and use it?
make sense to me but almost 20 years after someone began the Safe C library it's still a work in progress?
https://jacobfilipp.com/DrDobb... [jacobfilipp.com]
Re: don't get it (Score:2)
Oh, now I get it. (Score:2)
Rust Performance vs C Performance [rustfaq.org]
Memory Management in Embedded Systems: A Comparative Analysis of C and Rust [parvezshaik.info]
You use Rust's safety features while writing / debugging, but
turn off Rust's safety features (cargo run --release), when you're done.
That way you don't get abysmal performance from performing safety checks.
Although, couldn't this be done in C as well?
Re: (Score:2)
turn off Rust's safety features (cargo run --release), when you're done.
That's like removing your seat belts after the vehicle crash tests are done.
Re: (Score:2)
No. Not even close.
Re: (Score:2)
Although, couldn't this be done in C as well?
It can be. But it requires high coders skills and insights. In Rust the skill requirements are probably a bit (not that much) lower, but since Rust is hard to learn, you force competence in an indirect way. Yes, stupid, but that is one of the hoops needed to convince clueless "management".
Re: Oh, now I get it. (Score:3)
Weâ(TM)re already doing this (Score:3)
https://www.cs.wisc.edu/2025/0... [wisc.edu]
And DARPA has a whole program for it:
https://www.darpa.mil/research... [darpa.mil]
PhD Be Vibe Codin' (Score:1)
They see me vibe codin', they hatin', tryin' to catch me debuggin' dirty. Tryin' to catch me debuggin' dirty. Tryin' to catch me debuggin' dirty. Tryin' to catch me debuggin' dirty. My IDE is open, my terminal is glowing, and my Spotify playlist is riding heavy. Think I'm just copy-pasting Caude Code, but I'm a fully funded PhD candidate.
It's not the language it's the management (Score:2)
Re: (Score:1)
The problem with C is that it is easy to learn, but hard to master. The primary advantage of Rust is that it is hard to learn and hard to master. That keeps the idiots out and it probably its most significant actual security advantage.
Re: It's not the language it's the management (Score:2)
Some parts of C are easy to learn but pointers, particularly double and beyond , plus pointers vs arrays, tends to trip up the no hopers.
Probably compiler level (Score:1)
In other words... (Score:2)
More Doctors Smoke Camels Than Any Other Cigarette (Score:2)
It is not about the language even though one might consider to use C++ (not rust!). But Ubuntu is doing all the rewrites because of licenses and control. These stupid GNU tools are GPL and that's bad when you try to transition to an open core business model.
They are also developed by people with strict principles not makeing trade-offs when it comes to freedom and user-first design. You can't get GNU to serve corporate interests. Look at how much incompatibility the rust coreutils caused. But they still keep using them, telling people they are more secure. If someone knows hot to write secure and performant code it is certainly the GNU project.
If it were about safe programming alone they would transition to C++ by first embedding the C code into a C++ project and then slowly replacing C idioms with C++ ones. Rust is about rewrite for the sake of rewriting.
Dude, you can throw as many words at us as you like and your argument even sounds compelling...so long as we forget everything we see and know. C++ has LOTS of memory safety issues. We see these vulnerabilities and many crashes in C++ projects as well as C. I don't work with either, but I use many products written in both and see the results.
You remind me of those ads they ran in the 40s about safer cigarettes and which literally said "More Doctors Smoke Camels Than Any Other Cigarette." Only a moro
Re: (Score:2)
C++ has developed at lot over the last 20 years, and my understanding from C++ programmers is that there are now safe alternatives to virtually everything that had to be done using unsafe code in the past. So as long as you restrict yourself to those modern features, you can produce entirely safe C++, C++ that's as safe as Rust.
The problem with C++ is more that you have no idea what you're getting when someone drops a C++ source code bomb on you. It might be written using safe idioms, it might be using unsa
Re: More Doctors Smoke Camels Than Any Other Cigar (Score:2)
When Rust has anything approaching a useful OO model get back to me. Sure, it may be great for to the metal bit twiddle stuff where it can fight it out with C, but for writing a large user space application? Yeah, oink flap.
It's still garbage ... (Score:2)
It was still crap when it was all over and the project was flushed. The biggest sin was the naming conventions used by the original code were maintained.
I've migrated code from one language to the other, and the best end results I've achieved were when I reverse engineered the original code and wrote the new code from scratch. It took longer, but in the proc
Re: (Score:2)
To me, that implies the QA people were running a new test that had not been run on the original code. If it had been run on the original code, they would have produced the same results.
The question to ALWAYS ask the QA people in this circumstance is, "what was the result when you previously ran this test on the prior product?" This question could ha
Re: (Score:2)
As always, remember the warning (Score:2)
Eventually, everything turns to Rust [9cache.com].
Readable code. (Score:1)