logoalt Hacker News

Eurydice: a Rust to C compiler (yes)

162 pointsby todsacerdotitoday at 1:41 AM90 commentsview on HN

Comments

jll29today at 1:57 PM

The original author of the post also

- has designed the Mezzo programming language in his Ph.D. thesis and

- has worked on generating user-friendly C automatically. Most tools that generate C output pretty unreadable/unmaintainable code that you won't like to maintain, so this is a much under-researched topic.

bloppetoday at 8:32 AM

Rust compiles to LLVM IR. I'm pretty surprised that building this transpiler was considered a better use of time than writing an LLVM backend for whatever "weird embedded target" might need this.

show 6 replies
mustache_kimonotoday at 3:26 AM

Cool. One should perhaps mention some prior art:

    rustc_codegen_clr is an experimental Rust compiler backend(plugin), which allows you to transpile Rust into .NET assemblies, or C source files.[0]
[0]: https://github.com/FractalFir/rustc_codegen_clr
apitmantoday at 5:40 AM

I use Rust and C at work. I quite enjoy Rust, but I currently have no reason to believe C won't outlive it, by a lot.

show 7 replies
exDM69today at 11:00 AM

The project itself is cool and useful but the motivating example of crypto (primitives?) isn't great.

Cryptography is already difficult to write in high level languages without introducing side channels via timing, branch predictor, caches etc.

Cryptography while going through two high level compilers, especially when the code was not designed and written to do so is an exercise fraught with peril.

Tbf, this is just nitpicking about the article, not the project itself

show 1 reply
oconnor663today at 4:57 AM

> We recommend using Nix to easily ensure you are running the right versions of the tools and libraries.

Ooof I remember when everything used to be like this. Cargo has really spoiled me.

show 2 replies
Suractoday at 2:16 PM

I was always told rust uses llvm tokens not produceable by c code to do its magic. Was I informed wrong?

show 2 replies
d-lisptoday at 11:28 AM

When you think about it, Perseus did use Medusa's head to transform things into stone.

In fact he turned king Polydectes and all of his followers into stone when he went back to Sephiros.

Perseus defeated Medusa by not looking at her in the eyes.

Rust in a sense, allow you to solve problems without having to look directly at memory unsafe behavior.

I would have called this project "Medusa".

Aissentoday at 9:40 AM

> for instance, Rust panics on integer overflow

By default, this is only in debug mode. I recently forgot to add it to release mode on a project, and was surprised when I broke the CI (tests run in debug, I only tested in release mode).

pankajdohareytoday at 9:29 AM

In a world where Crabs are trying to rewrite everything in their favourite Crab Speak its nice to see the Reverse. I wonder if it coulkd be used to translate Rust compiler itself to C :-D

show 1 reply
opemtoday at 8:19 AM

Cool, loved this! These tools would be needed in the near future to manage the tech debt safe rust is compounding.

BobbyTables2today at 6:10 AM

Not saying it isn’t neat, but WHY?

Seems like the kind of thing that happens before a language is natively supported by a compiler.

show 4 replies
nutjob2today at 6:31 AM

Another Rust compiler with a C backend:

https://github.com/thepowersgang/mrustc

IshKebabtoday at 10:18 AM

The perfect headline to bring the anti-Rust luddites out of the woodwork...

hexotoday at 8:39 AM

So this means I can completely get rid of rust. Yay