News for hackers. Stuff that matters.
Re:C2Rust: translate C into Rust code by taneq on Saturday June 23, 2018 @01:18PM (#17382237)
Sounds like a case of "writing C in Rust" compared with "writing Rust". You're not really writing in a language until you're thinking in its idioms.
Re:C2Rust: translate C into Rust code by FreeFull on Saturday June 23, 2018 @01:58PM (#17382442)
A translator like this is still really useful as the first step of transforming a C codebase into a Rust codebase. The important thing is to get working code first, and then you can modify the code to be more idiomatic.
Re:C2Rust: translate C into Rust code by masklinn on Saturday June 23, 2018 @01:31PM (#17382304)
> Sounds like a case of "writing C in Rust" compared with "writing Rust".

Duh? It's literally taking C code and generating Rust code which behaves the same.

> You're not really writing in a language until you're thinking in its idioms.

The entire point is to get your foot in the door.

This gives you a pile of Rust code which (bugs aside) should behave the exact same way C code does.

From there on you're living in the Rust world and can improve that as you see fit.

If you can afford doing the initial transition in one short, later improvements are much simpler than having to maintain an internal (moving) front between remaining C code and new Rust code as e.g. librsvg does.

Re:C2Rust: translate C into Rust code by lomnakkus on Sunday June 24, 2018 @02:29AM (#17385273)
> If you can afford doing the initial transition in one short, later improvements are much simpler than having to maintain an internal (moving) front between remaining C code and new Rust code as e.g. librsvg does.

That's all well and good... if you don't have to maintain the project while doing the necessary C-as-Rust -> "proper" Rust conversion. This C-as-Rust output seems[1] like it woul d be incredibly difficult to do bugfixes in and there's also the issue of what happens if the C code happened to rely on implementation-defined behavior (or even UB which the implementation happens to "do the right thing" with).

Unless you have a trivial amount of code, I'd say the right thing is to do the conversion in small chunks. This also gives you a much better way to ensure (through test suites) that you're not introducing excessively many new bugs when rewriting C-as-Rust to "proper" Rust.

[1] I realize this is early days, but I'm talking about the present time.