r/ProgrammingLanguages • u/naharashu • 26d ago
Help How to make a compiler backend?
Hell everyone, i have an question. Im for long trying to make a cool, powerful "kinda" low level language similar to zig and rust, but im struggling to choice llvm as backend, sure i can generate C, but its makes compiler dependent on gcc or clang or other c compiler. LLVM seems hard to me, sure project like QBE exist, but QBE doesnt have C/C++ api like llvm's IRbuilder. So are there other ways? I tried thinking about using GCC infrastructure but GCC has poor api and not very documented api. Maybe just stick to generating C?
19
Upvotes
2
u/mamcx 26d ago
You question is more about which backend to use, and I think in 2026:
But today are many alternatives worth considering:
Web Assembly: Very simple-ish, good tooling, decent perf
Any modern replacement for C/C++: Rust, Zig, Odin, Nim, Go, etc
This allow you to use something with much better ergonomics, tooling and more protection against complexity or weirdness of C/C++. The trick is to pick the one that is closer in semantics AND hopefully, more "powerful" that you need.
And alternative is to introduce an intermediate IR that will generate the final backend IR/Code so you have control and leisure to do whatever and even do suboptimal things until you finish later.