Live data from Hacker News

Rust to C compiler – 95.9% test pass rate, odd platforms

fractalfir.github.io

31–40 of 264 posts

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#31
post #21

Of course, everyone votes up the headlines, but this link seems like premature WIP. Hopefully this will get posted for real after the presentation.

I clicked through to the project at https://github.com/FractalFir/rustc_codegen_clr - from a quick glance at it, with 1.8k stars and 17 contributors, it deserves a better treatment than a passive—aggressive dismissal like this as a top comment.

It is a very impressive piece of work.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#32
post #21

Of course, everyone votes up the headlines, but this link seems like premature WIP. Hopefully this will get posted for real after the presentation.

Yeah, exactly. Here on a website called 'Hacker News', we're only interested in projects when they're feature complete and mature enough for production deployment, not before. (/s)

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#36
post #34

At first I read it as C to rust compiler. What is the point of compiling rust to C?

I think there are probably C compilers for more platforms than there are rust compilers. So, if you want to compile your rust project on some obscure platform that doesn’t have a rust compiler for it yet, you could compile to C and then compile the resulting C code for that platform?

Just a guess.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#39
post #9

Very cool. C to Rust would be fantastic.

> C to Rust would be fantastic. This would have to go into one big unsafe block for any nontrivial program. C doesn’t convey all of the explicit things you need to know about the code to make it even compile in Rust.

If your translator is correct, the rust front end enforces the semantics of rust then C implements them. It's as safe as any other implementation.

If that feels uncomfortable, consider that x64 machine code has no approximation to rust safety checks, and you trust rust binaries running on x64.

"Correct" is doing some heavy lifting here but generally people seem willing to believe that their toolchain is bug free.

Re: Rust to C compiler – 95.9% test pass rate, odd platforms

#40
post #7

Lots of interesting use cases for this. First one that comes to mind is better interop with other languages, like Python.

The interop is already great via PyO3, except when people want to build the Rust part from source, but are grumpy about having to install the Rust compiler.

This hack is a Rust compiler back-end. Backends get platform-specific instructions as an input, so non-trivial generated C code won't be portable. Users will need to either get pre-generated platform-specific source, or install the Rust compiler and this back-end to generate one themselves.

Post reply on HN