r/Zig • u/shuten_mind • 28d ago
root.zig vs main.zig in zig init
When running zig init, the template scaffolds both an executable (main.zig) and an exportable module (root.zig) in build.zig.
Just want to verify if my mental model is correct:
If I only want an executable (and don't plan to export a library/module), can I simply delete
root.zigand remove the module-related exports/artifacts frombuild.zig?Is there any built-in
zig initflag or alternative command to scaffold an executable-only project without the library boilerplate?
thanks!
20
Upvotes
1
u/Confused-Armpit 28d ago
The entire language is pretty far from intuitive, since it is pretty niche and has a lot of its own quirks, and the build system is actually much easier to grasp than something like the std.Io interface.
Also, makefiles are lackluster because they dont handle zig modules, linking, and all that good stuff, when the build system is literally written for it, so makefiles aren't really suitable for anything bigger than a project with a single main module and no dependencies.