News for hackers. Stuff that matters.
Re:Roc rewrites the compiler in Zig by petabyt on Tuesday February 04, 2025 @04:56PM (#42939469)
Fast compile times in Zig? Last time I tried it was super slow. Has anything changed in recent years?
Re:Roc rewrites the compiler in Zig by pverghese on Tuesday February 04, 2025 @05:14PM (#42939728)
Compared to Rust its blazingly fast. Compared to Go compilation its slower.
Re:Roc rewrites the compiler in Zig by metaltyphoon on Tuesday February 04, 2025 @07:08PM (#42941300)
Non it’s not. I known its not a benchmark but just try a zig init and build their hello world. It takes significantly longer
Re:Roc rewrites the compiler in Zig by sweeter on Tuesday February 04, 2025 @07:24PM (#42941480)
```sh

sweet@nadeko ~ $ mkcd test

sweet@nadeko ~/test $ zig init

info: created build.zig

info: created build.zig.zon

info: created src/main.zig

info: created src/root.zig

info: see `zig build --help` for a menu of options

sweet@nadeko ~/test $ time zig build

zig build 5.08s user 0.58s system 119% cpu 4.745 total

# cached

sweet@nadeko ~/test $ time zig build

zig build 0.01s user 0.03s system 132% cpu 0.026 total

# after rewriting the main function to call a function that takes a pointer to another function

sweet@nadeko ~/test $ time zig build

zig build 0.02s user 0.03s system 136% cpu 0.032 total

```

Re:Roc rewrites the compiler in Zig by baazaa on Wednesday February 05, 2025 @01:00AM (#42944437)
think this has something to do with zig building part of the std which other languages ship as binaries. incremental compilation will remove this small overhead.
Re:Roc rewrites the compiler in Zig by jedisct1 on Wednesday February 05, 2025 @12:57PM (#42952457)
The first time you run the toolchain for a given target, it compiles stuff that is then stored in a global cache.
Re:Roc rewrites the compiler in Zig by modernerd on Tuesday February 04, 2025 @05:35PM (#42940023)
Last time I tried it was missing both speed and incremental compilation. That still looks to be the case due to no linker support.

https://github.com/ziglang/zig/issues/21165

Re:Roc rewrites the compiler in Zig by rererereferred on Tuesday February 04, 2025 @05:16PM (#42939748)
Their x86 backend seems to be more complete, bypassing LLVM and allowing for fast debug builds.
Re:Roc rewrites the compiler in Zig by zozbot234 on Tuesday February 04, 2025 @05:24PM (#42939850)
Rust has a Cranelift-based backend that you can use for that.
Re:Roc rewrites the compiler in Zig by bhansconnect on Tuesday February 04, 2025 @05:57PM (#42940353)
It sadly helps a lot less than you would hope. A true dev backend can be many times faster than llvm to compile code. Crane lift is more like a 1.5x or 2x. Not to mention a lot of time is spent in the rust frontend.
Re:Roc rewrites the compiler in Zig by sweeter on Tuesday February 04, 2025 @07:18PM (#42941423)
Its honestly pretty dang good now. I can bootstrap Zig from C in about 3-5 minutes, and then use the self-hosted stage3 compiler to compile Zig very quickly (under 1 minute iirc) Once the cache kicks in, its even faster. I guess my overall gauge on this is the impression I get. Zig build times never annoy me and I never think about it... especially compared to clang, gcc and Rust.