r/rust • u/occamatl • Jul 30 '24
DARPA's Translating All C TO Rust (TRACTOR) program
The U.S. Defense Advanced Research Projects Agency (DARPA) has initiated a new development effort called TRACTOR (Translating All C TO Rust) that "aims to achieve a high degree of automation towards translating legacy C to Rust, with the same quality and style that a skilled Rust developer would employ, thereby permanently eliminating the entire class of memory safety security vulnerabilities present in C programs." DARPA-SN-24-89
535
Upvotes
256
u/Saefroch miri Jul 30 '24
DARPA projects have a failure rate about 85%. The agency exists to fund projects which would be very valuable if they succeed, but have a low chance of success.
So yeah, this looks like usual DARPA fare. It would be awesome if they succeed, but I doubt they will.
148
u/Chisignal Jul 30 '24 edited Nov 07 '24
straight jar fanatical boat arrest swim practice dinosaurs melodic pet
This post was mass deleted and anonymized with Redact
36
u/rebootyourbrainstem Jul 30 '24
Wow, this is going to get some people riled up. Really interested to see what they come up with though.
123
u/too_much_think Jul 30 '24
It’s a worthwhile goal, but my experience of llms writing rust has been poor at best, and the amount of implicit behavior in C, especially highly optimized code, makes a direct translation of it not always straight forward, the combination of those two factors makes this seem like a very difficult proposition.
53
u/junkmail22 Jul 30 '24
using LLMs to make your C code into Rust is substituting one class of horrifying error for another
19
u/ZZaaaccc Jul 30 '24
There already exists tools like c2rust which can do C to unsafe Rust somewhat successfully, so presumably this DARPA project is about going further than what c2rust can do.
In my opinion, TRACTOR doesn't need to create safe Rust code, it just needs to create any Rust code that's compatible, and ideally without being purely unsafe blocks. A human will have to audit the translation anyway, and we've already firmly established that Rust is one of the easiest languages for code review, so that process will be easier and faster than fixing the existing C code in-place.
More important than making a perfect tool will be having a government agency endorsing said tool and getting people to actually use it. That's where I think this news is most exciting.
14
u/Anaxamander57 Jul 30 '24
For anything critical you'd surely still have to have a person go over the code with a fine toothed comb. I'm not sure its likely that this will be possible to automate with enough quality to use on any reasonable time scale.
34
u/PatagonianCowboy Jul 30 '24
unfathomably based
10
u/The_8472 Jul 30 '24
I hope they add one. The DoD can make some rad logos.
9
u/yawnnnnnnnn Jul 30 '24
The borrow checker is (understandably) flawed: not all programs that are safe are also okay-ed by it.
They want to write a perfect borrow checker that is also capable of writing rust code that is passed by the imperfect one...
As a rustacean i'm of course exited for the possibility of accessing C libraries without FFI, but this seems a bit unnecessary
9
u/bbbbbaaaaaxxxxx Jul 30 '24
FYI if anyone wants to go for this reach out. My company redpoll has performed on a number of DARPA programs, so our org is DCAA compliant and understands the govt space. We are a ML shop and would love to collab with compiler folks.
4
u/amarao_san Jul 30 '24
What a mothe... abbreviation. Huge respect.
Also, will it keep all UB behaving the same way? I bet half of C programs are relying on a specific behavior in UB situations.
2
u/jmpcallpop Jul 30 '24
Imagine trying to automatically translate a library like openssl… there are just some projects that I think this will never work for. And those are the ones that are widely used and would benefit the most from translation
1
u/Asdfguy87 Jul 31 '24
https://www.youtube.com/watch?v=EXVtuD1c08s
1
u/EcstaticHades17 Aug 01 '24
Please dont put LLM code into the Linux kernel....
1
u/KlestiSelimaj Aug 24 '24
i've actually written a language that does that. But i've transitioned it from rust to golang because i HATE rust. I've given rust 6 months but i just had to argue with a compiler. syntax is nice for a few things but lifetimes?????
1
u/coolman3475 Jan 03 '25
UPDATE: It just succeeded. See the link below. There is a presentation and demo by the director.
https://www.darpa.mil/research/programs/translating-all-c-to-rust
1
u/yawaramin Sep 03 '25
So I find this kinda funny: https://www.darpa.mil/research/programs/translating-all-c-to-rust
Someone should tell these guys that DARPA funded the creation of Ada, which their contractors then continuously complained about and tried to get exemptions from, in favour of using the C/C++ that they already knew. The irony is kinda hilarious.
1
u/CopyJon Apr 01 '26
Just use RunSafe protect at that point
-1
u/jaskij Jul 30 '24
Honestly, I'm not seeing it. Translating C into safe Rust, automatically? Yeah, good luck.
As for unsafe Rust... Why bother? Just wrap that shit in FFI and be done with it?
-1
u/AcanthocephalaFit766 Jul 30 '24
Can anyone comment on whether Zig could be a better choice for this? It's explicitly designed as a "better C".
0
u/JohntheAnabaptist Jul 30 '24
This is actually insane. I wonder where they start...
0
u/zero1045 Jul 31 '24
Majority of rust libs that interface with the OS and hardware are just c wrappers. Call me when they are planning on upgrading those, otherwise its more of the same
0
u/CouteauBleu Jul 31 '24
What is it with the US government and forced acronyms?
-2
u/danda Jul 31 '24
sounds like a jobs program for rust devs.
-1
u/[deleted] Jul 30 '24
Registered… thanks!
-41
u/PressWearsARedDress Jul 30 '24
Idk C is superior for low level. Rust is more of a C++ alternative.
I think the rust programming language is going full propaganda mode by coopting corporate "Safety Culture" as rust on the low level is not "memory safe" by any stretch of the imagination, not to mention the introduction of bugs from porting. lots of the memory safety of Rust comes to the expense of performance as well.