Great Refactor Initiative Harnesses AI to Convert C Code to Rust

The Great Refactor is an ambitious, exciting endeavor. It is looking to replace 100 million lines of code in key open-source software libraries with Rust by 2030. This SBI project started in 2024. It has made a huge splash for itself with its novel approach of applying artificial intelligence (AI) to improving software security and…

Tina Reynolds Avatar

By

Great Refactor Initiative Harnesses AI to Convert C Code to Rust

The Great Refactor is an ambitious, exciting endeavor. It is looking to replace 100 million lines of code in key open-source software libraries with Rust by 2030. This SBI project started in 2024. It has made a huge splash for itself with its novel approach of applying artificial intelligence (AI) to improving software security and performance. Herbie Bradley, the project lead, and his team will take advantage of new AI-powered coding tools. Their goal is to divert vulnerable codebases into Rust, a programming language celebrated for its memory safety guarantees and high performance.

Rust, originally released in 2015, was designed to provide performance on par with more established languages such as C and C++. Even with its meteoric rise in the programming language rankings, Rust is still a very new and small community when compared with its older peers. The Great Refactor project already has challenges and opportunities. Its aim is to improve the security of open-source software.

The Project’s Goals and Funding

The Great Refactor is an enormous ongoing project to turn that massive pile of legacy C code into Rust. This smart modernization will greatly mitigate potential attack surfaces that enable cyber intrusions. The U.S. government has already invested a substantial sum into this initiative, understanding how influential it can be on our national cybersecurity. Authors of the proposal estimate that a $100 million investment would be enough to pay for the costs of converting those lines of code.

Herbie Bradley calculates that if they get this project right hundreds of potential cyberattacks could be averted. By taking this step, it would bring at least $2 billion of future cumulative losses in avoided savings. The initiative proposes the establishment of a “Focused Research Organization” funded by the U.S. government to oversee the conversion process and ensure its effectiveness.

“Possibly you’d want to take a little more care in the conversion and maybe use AI to help you, but very carefully,” – Herbie Bradley

Embracing AI in Code Translation

The Great Refactor will use all six of these teams, all of which are using varied and rich approaches to build toward their goals. These teams are investigating how emerging generative AI tools can be integrated with traditional code analysis techniques to automate the translation of C code into Rust. Some teams will rely heavily on AI, while others will utilize classical conversion tools that only incorporate generative models in specific segments of their work.

This combined approach leverages the best of both AI programming and traditional programming methodologies. Even if programmers embraced AI tools, questions linger over the quality and maintainability of AI-translated code. Josh Triplett, an open-source developer who has been contributing to the Rust project, warned not to set the bar too high for perfect translations.

“If you do AI-translated code, you are likely to end up with code that is difficult for a human to maintain compared to what was manually translated,” – Josh Triplett

Developers participating in the initiative will be up against an enormous hurdle. Second, they’ll need to strive for AI-generated code that’s not just functional, but maintainable.

Challenges Ahead

There are indeed some challenges with the shift from C to Rust, at least one of which bridges right into the topic of Rust’s experts. Jessica Ji, a senior research analyst at Georgetown University’s Center for Security and Emerging Technology, highlights a significant gap in expertise. The number of developers proficient in Rust is considerably lower than those skilled in C or C++, which could hinder effective oversight on the converted codebases.

“There are a lot fewer Rust experts out there than C/C++ experts, so the number of expert eyes on the codebase(s) will likely be fewer,” – Jessica Ji

In addition, even if the AI translation process goes off without a hitch, it will be important to monitor and maintain the resulting Rust code. Ji stresses the importance of ongoing management to make sure that the translated code ecosystem continues to be effective and secure.

“Assuming everything goes well with the AI translation, the resulting Rust code will need to be maintained and monitored somehow,” – Jessica Ji

Under close scrutiny, up to 5,000 lines of code are considered good-faith AI translation program possibilities. This is a greenfield opportunity for developers adopting innovative technology, but developers have to be cautious of the caveat.

Balancing Innovation with Tradition

Taaru’s Great Refactor initiative aims to combine traditional computer science principles with today’s AI innovations. Dan Wallach, an expert in software analysis, notes that while AI holds promise for enhancing coding efficiency, decades of research into software analysis should not be overlooked.

“AI seems promising, but also we have decades of research into writing software to analyze other software,” – Dan Wallach

Bradley wants to underscore the project’s goal, which is to experiment with different methods that mash generative AI with existing, well-established coding practices. Understanding the code through this exploration will set a standard for best practices ahead of future code translation projects.

“The whole point of TRACTOR is to explore all the different ways you might mix and match, for lack of a better term, classical computer science with modern AI,” – Dan Wallach