Also I have some bad news for you...
> One major caveat: after the above stages have finished, a C compiler still needs to run to generate the final binary, which usually takes up the most time. The LLVM backend will (hopefully) reduce this.
Nope. LLVM is about 80% of the time that it takes to compile Zig code. Other language authors have found similar results. See for example http://pling.jondgoodwin.com/post/compiler-performance/
Anyway, Godspeed. I'll be watching Muon with interest :-)
Edit: one more question, if I may:
> No undefined behavior. Undefined behavior can lead to various, hard-to-spot, bugs. In Muon, all behavior, including platform-specific behavior, is defined.
> The compiler currently outputs C code.This means that we inherit C's undefined behavior model, which goes against the goals listed above! An LLVM backend is in the works which will avoid any undefined behavior.
> High performance. Strive for parity with C.
How are these things to be reconciled? First of all LLVM IR and C have basically the same undefined behavior model. In both C and LLVM IR it's possible to output well-defined code. But more confusing to me is how it's supposed to be fast, if everything is defined?
For example: https://godbolt.org/z/7d8RLG
export fn add1(a: i32, b: i32) bool {
return (a - b) > 0;
}
export fn add2(a: i32, b: i32) bool {
return (a -% b) > 0;
}
In this Zig code, we see 2 implementations of a function. `add1` has undefined behavior if `a - b` overflows. `add2` has defined behavior: wraparound arithmetic. The assembly code, with optimizations on: add1:
cmp edi, esi
setg al
ret
add2:
sub edi, esi
test edi, edi
setg al
ret
You can see that the version with undefined behavior has 1 fewer instruction. How can you expect to compete with C (or Zig's) performance without undefined behavior?