Forgot your password?
typodupeerror
Programming

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.

Canonical is Funding a PhD to Automate C to Rust Translation

Comments Filter:
  • by dskoll ( 99328 ) on Sunday August 23, 2026 @10:43AM (#66303154) Homepage

    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.

    • by allo ( 1728082 )

      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

      • by AmiMoJo ( 196126 )

        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.

        • by allo ( 1728082 )

          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

      • 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

        • 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)

      by gweihir ( 88907 )

      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

      • by dskoll ( 99328 )

        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.

        • So, nobody knows how to code in C anymore is the reason for wanting to transcode all C to Rust?

          • 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.

    • It will be crusty for sure
    • 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%.

  • by fluffernutter ( 1411889 ) on Sunday August 23, 2026 @10:44AM (#66303158)
    Why not just use the time to make a safe c library of operations and use it?
    • by haruchai ( 17472 )

      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]

      • That's general purpose. The company could write it to be specific to them. Don't have a hundred different inventions of an array from a pointer with a counter, write one and test it and use it everywhere.
  • 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?

    • 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.

    • by gweihir ( 88907 )

      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".

    • Because the point of Rust is that it's safe by design. In other words, once you've figured out how to structure your program to make it not do unsafe things, you have a design you can just implement in C and (as long as it's a faithful implementation), and it will also be guaranteed to be safe. The only reason not to is that maintenance is harder that way. It also shows that Rust has to many limits because code that is provably safe by a human cannot be written in Rust without a redesign to meet Rust's more
  • 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.

  • The C code at most large companies I've worked at has been total crap. My high school CS teacher probably wouldn't have accepted the code from my last company even to mark it since it lacked descriptions of the projects and comments. This isn't something that can be fixed with a new language. C at least won't compile if someone is an idiot so usually about 25% of the C devs are worth the air they breath which is far better than the JavaScript devs. The issue is managers wanting steady, easy to measure progr
    • by gweihir ( 88907 )

      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.

  • I see most comments are assuming this is done with AI but this isnâ(TM)t necessary. It would make more sense to compile C to the intermediate code, then generate rust that would generate the same intermediate codes. As for unsafe rust it would be a huge win to translate all the regular C to rust, and only have some sections that need unsafe rust, vs the entire code base being essentially unsafe. An upshot of conversion might be the automatic converter canâ(TM)t find a safe equivalent for some c co
  • In other words, they are throwing their money to influence an open source project.
  • Translating garbage code creates even worse garbage code. I remember years ago a company I was with hired a company to translate COBOL to Java.

    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
    • I loved it when the QA people would come back to me and say the results weren't the same, only to discover the original program had an undiscovered error.

      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

  • Translating code from one language to another is not that hard. Getting code that was translated that can be easily maintained is difficult.

"I'll rob that rich person and give it to some poor deserving slob. That will *prove* I'm Robin Hood." -- Daffy Duck, Looney Tunes, _Robin Hood Daffy_

Working...