February 9, 2026

C vs Rust: comment section cage match

Thoughts on Generating C

He picks C for code generation; Rust fans show up with receipts

TLDR: A compiler engineer lays out why generating C—with inline helpers and strict conversions—keeps code fast and safer. Commenters debated Rust, complained about flaky tail-call support, and shared debugging hacks like #line, highlighting real-world pain points and why practical, debuggable codegen matters.

The author says generating C (not writing it by hand) is the sweet spot for compiler folks: use always-inline helpers to erase overhead, be strict about number conversions, and wrap raw pointers in tiny structs so you don’t mix up addresses. Cue the C vs Rust showdown in the comments. One reader cheered the preemptive “why not Rust?” aside, while Rust fans rolled in like a flash mob. Another veteran warned that the much-hyped “tail call” attribute isn’t reliable across big-name compilers, sparking a mini brawl over what you can actually trust in production. Debugging drama? Oh yes. The author admits source-level debugging is gnarly without DWARF (a common debug info format), and a commenter drops a clever hack: slap #line markers so tools like GDB think your generated C lines map back to your original code. Meanwhile, a builder planning to JIT their own scripting language into shared libraries nods along like, “Yep, this is exactly what I need.” And a curious soul asks if we can just use a strict subset of C—translation: “Can we have C without the chaos?” The mood: pragmatic love for C-as-target, spicy side-eye at compiler quirks, and plenty of jokes about C being the cockroach that survives every tech apocalypse.

Key Points

  • Generating C can avoid many hand-written C pitfalls, but requires disciplined patterns.
  • Use static inline (always_inline) functions for zero-cost data abstractions instead of macros for data access.
  • Model memory access with structs and inline helpers; optionally elide bounds checks by relying on PROT_NONE mappings.
  • Be aware of ABI differences (e.g., AArch64 vs System V x86-64) that affect struct returns; inlining mitigates overhead.
  • Avoid implicit integer promotions by using explicit conversion helpers and enabling -Wconversion; encapsulate casts in helpers.

Hottest takes

"why not generate Rust?" — rirze
"must_tail ... can't be relied on" — whizzter
"#line 12 \"source.wasm\"" — Joker_vD
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.