Zig's Andrew Kelley: "The compiler is too dam slow, that's why we have bugs..."

Matheus Catarino matheus-catarino at hotmail.com
Wed Jan 31 14:42:23 UTC 2024


On Wednesday, 31 January 2024 at 01:24:35 UTC, Don Allen wrote:
> On Tuesday, 30 January 2024 at 17:12:56 UTC, Walter Bright 
> wrote:
>> It would certainly slow me down if the edit-compile-debug loop 
>> of the compiler was longer than a few seconds.
>
> Yes, of course it would. But would you attribute bugs 
> accumulating at too fast a rate **solely** to "the compiler is 
> too damned slow" and make a public announcement about this 
> epiphany?
>
> The Zig compiler, which I've used a fair amount, including the 
> new self-hosted non-llvm version, is not as fast as DMD, but 
> it's not that far off. It is nowhere near as slow as the Rust 
> compiler or GHC. Neither the Rust project nor the GHC project 
> is accumulating bugs at the rate the Zig project is.

**DMD version:** DMD64 D Compiler v2.106.1 (linux x86_64)
**Zig version:** 0.12.0-dev.2341+92211135f [master] (linux x86_64)

both examples have:

```d
void main(){}
```

```zig
pub fn main() void{}
```

**Self-hosting compilers - peformance**

```bash
$> hyperfine --warmup 5 'dmd -i hello.d' 'zig build-exe -fno-llvm 
-fno-lld hello.zig'
Benchmark 1: dmd -i hello.d
   Time (mean ± σ):     109.9 ms ±   1.6 ms    [User: 52.8 ms, 
System: 56.7 ms]
   Range (min … max):   108.1 ms … 114.3 ms    26 runs

Benchmark 2: zig build-exe -fno-llvm -fno-lld hello.zig
   Time (mean ± σ):     334.3 ms ±   3.5 ms    [User: 246.5 ms, 
System: 155.6 ms]
   Range (min … max):   329.1 ms … 342.2 ms    10 runs

Summary
   dmd -i hello.d ran
     3.04 ± 0.05 times faster than zig build-exe -fno-llvm 
-fno-lld hello.zig

```

**Glossary flag:**

- `-fno-llvm`: replace llvm backend to zig backend [wip].
- `-fno-lld`: replace llvm-lld (builtin) to zld (self-hosted zig 
linker).



More information about the Digitalmars-d mailing list