I'm guessing the reason for doing it this way is to avoid having to invent a build language. Instead, Zig is used as the "scripting" language for the build.
Compare with Bazel's Skylark language, which is approximately a subset of Python.
Since an imperative language is doing declarative things, there can be a bit of confusion unless you're clear about how it works.
It's one of the things I really appreciate about zig. This resonates with the notion that the whole language should be available at compile time, instead of a bolt-on macro language. The language is great, and I love that it aims to bootstrap itself in all of the things.
I’m not sure if I like or dislike this, actually. On one hand, this feels like the same boring old case of “every language wants to be an operating system”, which is perhaps most apparent in build systems (see Ant, Rake, Grunt, etc.), and I don’t think that’s generally a good thing (even if it might be forced upon us by the realities of current operating systems). On the other, I have a certain affection for the clarity of MLton’s ML Basis[1] approach (essentially, “allow people to use filenames in let statements”), which is, on reflection, a (declarative) build system embedded in a language.
I spend a lot of time in Python, which has an explosion of incompatible build stories, packaging systems, etc. They use several data formats (did the world ever need toml?) and lately, they've deprecated the previously-recommended gold standard. Having a single blessed system that ships with the language is a breath of fresh air. Though, as far as I know, zig packaging is still wide open looking for solutions -- but Andy has expressed intent to pick one and support it.
Same feeling here. Which is why I aggressively promote it whenever I have the chance to do so. Would love to see it expand more in the professional world.
Compare with Bazel's Skylark language, which is approximately a subset of Python.
Since an imperative language is doing declarative things, there can be a bit of confusion unless you're clear about how it works.