News for hackers. Stuff that matters.
Re:Ask HN: A retrofitted C dialect? by woodrowbarlow on Tuesday February 25, 2025 @01:08PM (#43175267)
> source-level compatibility with C

not sure if this is exactly what you meant, but in Zig you can #include a C header and then "just" invoke the function. no special FFI syntax or typecasting (except rich enums and strings). it can produce compatible ASTs for C and Zig.

Re:Ask HN: A retrofitted C dialect? by anqurvanillapy on Wednesday February 26, 2025 @10:03AM (#43184278)
Notable approaches to compatibility with C might be: 1) LLVM, like Rust and Zig did (Zig stopped using it in 2023), since LLVM IR is good for being compatible and optimizing. 2) Other backends like libgccjit, I mentioned this because rustc has a libgccjit backend and its author who is a libgccjit maintainer loves the simplicity of it, one could also think of it as a programmable GCC. 3) Code generation directly to C, that's what Koka does.

So I was talking about the direct C codegen approach, but there's still much of some mess like one needs to choose a C standard and knows how to verify the generated code.