Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Some users want a C backend, not for maintainability reasons, but for the ability to compile on platforms that have nothing but a C compiler. The maintainability or aesthetics of the C is irrelevant, it's like another intermediate representation.


Can confirm, Zig's generated C is extremely ugly. We literally treat it as an object format [1].

The MSVC limitations are maddening, from how short string literals must be, to the complete lack of inline assembly when targeting x86_64.

[1]: https://ziglang.org/documentation/0.14.1/std/#std.Target.Obj...


I bet it would be easier to write a code gen for such platforms than to wrassal generated C code and work around the endless problems.

Anyhow, one of the curious features of D is its ability to translate C code to D code. Curious as it was never intentionally designed, it was discovered by one of our users.

D has the ability to create a .di file from a .d file, which is analogous to writing a .h file from a .c file. When D gained the ability to compile C files, you just ask it to create a .di file, and voila! the C code translated to D!


Maybe, I don’t use those platforms and so I don’t know from experience, I just know that’s why people asked us in Rust.

I somehow missed that D has that! I try to read the forums now and again, but I should keep more active tabs on how stuff is going :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: