Hacker News new | ask | show | jobs
by anticrymactic 1192 days ago
What problem does c2Rust solve exactly? Isn't it just gonna produce "garbage" rust.

Calling c directly is already possible in rust.

8 comments

From c2rust.com:

The C2Rust project is being developed by Galois and Immunant. This tool is able to translate most C modules into semantically equivalent Rust code. These modules are intended to be compiled in isolation in order to produce compatible object files. We are developing several tools that help transform the initial Rust sources into idiomatic Rust.

The translator focuses on supporting the C99 standard. C source code is parsed and typechecked using clang before being translated by our tool.

This isn't about calling external C code from Rust; it helps people "rewrite" their C code in Rust.

You can debate the merits of doing so, of course, but some people do want to do that, and a tool to generate safe, somewhat idiomatic Rust from C code would seem to be useful.

It moves the project directly into rust land and tooling, which hopefully makes it easier to convert it without needing to set up multi langage tooling and a moving barrier / interface between the two langages.
The post does address this and shows their attempt to produce higher quality Rust. I've also seen it used to move off of a C toolchain and onto a pure Rust toolchain by porting C code to Rust.
The article shows what improvements they are thinking of so that it doesn't produce garbage rust. (If by garbage rust you mean unsafe rust.)
From reading the article, I get that the latest version can transform some C into safe Rust.

This gains us machine-proved memory safety. This is huge.

It helps by lowering the barrier to entry when working on rewriting a codebase in rust.
It makes it easier to get your project on the front page of HN as you can claim it is written in Rust.