> To give you an idea of what I am talking about, a full build of the Traction Point debug configuration, at a little over 100k LoC of Zig, takes around 24s. Changing a single line and rebuilding, with a warm cache, takes over 15s. C3 compiles the full game, without caching, in about 3s. I’ve seen it be as fast as 2.6s.
One thing I've never understood about Zig: if clang (and c3c) and Zig are both using LLVM for code generation, why is compiling so much slower in Zig for projects of similar size?
The vast majority of time is spent in LLVM, though, as reported by `--time-report`.
I did a little research and it looks like Zig puts everything into one module and feeds it to LLVM. That approach is inherently single-threaded because there's just one giant module. Clang, on the other hand, treats each translation unit as a module, so it works in parallel. Presumably c3c works the same but I'm not familiar with it.
I really wish Zig would parallelize the object file emission in a way that would benefit any selected backend (i.e. whether LLVM or their own backend).
I work on the Mach[0] game engine in Zig, and I would be curious to hear if the author tried running the Zig Windows executable build under WSL2 or not, targeting Windows via cross-compilation?
In my experience Windows filesystem is very very slow, and cross-compiling from WSL (which conveniently launches native Windows exe files outside of the VM when invoked in WSL2!) has been the better developer experience for me, i.e. via `zig build run -Dtarget=x86_64-windows` to build with a Linux compiler version, cross-compile for windows, and execute on the host Windows OS.
Either way, nice article - I hope you continue writing!
Love the SL3 idea! The c3c compile times are so fast (usually <5s) that it doesn't bother me, but my other solution is to embed a tiny JS engine - also written in C3 [1].
I've been writing a 3D renderer and game engine in C3 and having a blast, hopefully it will gain popularity for games. The language is solid, fast, free of traps, and much friendlier than Rust/Zig/etc.
The warm-cache Zig number is what would have made me switch too. 15 seconds to rebuild after changing a line in a 100k LoC project is long enough to break the loop; a 3 second full rebuild is a different kind of tool.
15s for a warm cache LLVM debug build for Windows sounds quite slow. My 10kLOC game takes 5s on a 8yo laptop, most of which is emitting LLVM of course.
> To give you an idea of what I am talking about, a full build of the Traction Point debug configuration, at a little over 100k LoC of Zig, takes around 24s. Changing a single line and rebuilding, with a warm cache, takes over 15s. C3 compiles the full game, without caching, in about 3s. I’ve seen it be as fast as 2.6s.
One thing I've never understood about Zig: if clang (and c3c) and Zig are both using LLVM for code generation, why is compiling so much slower in Zig for projects of similar size?
comptime and anytype don’t come for free
The vast majority of time is spent in LLVM, though, as reported by `--time-report`.
I did a little research and it looks like Zig puts everything into one module and feeds it to LLVM. That approach is inherently single-threaded because there's just one giant module. Clang, on the other hand, treats each translation unit as a module, so it works in parallel. Presumably c3c works the same but I'm not familiar with it.
I really wish Zig would parallelize the object file emission in a way that would benefit any selected backend (i.e. whether LLVM or their own backend).
I work on the Mach[0] game engine in Zig, and I would be curious to hear if the author tried running the Zig Windows executable build under WSL2 or not, targeting Windows via cross-compilation?
In my experience Windows filesystem is very very slow, and cross-compiling from WSL (which conveniently launches native Windows exe files outside of the VM when invoked in WSL2!) has been the better developer experience for me, i.e. via `zig build run -Dtarget=x86_64-windows` to build with a Linux compiler version, cross-compile for windows, and execute on the host Windows OS.
Either way, nice article - I hope you continue writing!
[0] https://machengine.org
Love the SL3 idea! The c3c compile times are so fast (usually <5s) that it doesn't bother me, but my other solution is to embed a tiny JS engine - also written in C3 [1].
I've been writing a 3D renderer and game engine in C3 and having a blast, hopefully it will gain popularity for games. The language is solid, fast, free of traps, and much friendlier than Rust/Zig/etc.
[1] https://github.com/ricardobeat/boomkat
Looks great. Btw your code commenting is heaven. Details everywhere, nicely formatted. Great learning resource
You're complimenting Claude and Gemini.
Congratulations! Super interesting. Will have to read in small portions because gray text on darker gray background slows my reading enormously,
At least in Safari, reader mode works well because the site is basically text.
The warm-cache Zig number is what would have made me switch too. 15 seconds to rebuild after changing a line in a 100k LoC project is long enough to break the loop; a 3 second full rebuild is a different kind of tool.
From the color palette alone, i can assume C3 is vibeslop, yeah?
Great post, goes into a lot of details.
I did a bunch of (tiny game jam) games in wasm, in C++, Rust, Zig and Odin, a while ago. I found Odin very pleasant at the time.
C3 also looks very pleasant. I haven't tried it yet. I might have to give it a go :)
I also haven’t tried C3, but Odin is my favorite of the rest. Pragmatic, simple, and ergonomic. I’m looking forward to working more with it.
Particle system is a weird example hot-reload -- wouldn't one prefer to generate compute shaders, and not cpu-side bytecode?
15s for a warm cache LLVM debug build for Windows sounds quite slow. My 10kLOC game takes 5s on a 8yo laptop, most of which is emitting LLVM of course.
The code in question is 10 times longer than yours.