# What is root.zig?

**URL:** <https://ziggit.dev/t/what-is-root-zig/5319>\
**Category:** Explain\
**Tags:** language\
**Created:** [July 23, 2024, 1:42pm UTC](https://ziggit.dev/t/what-is-root-zig/5319 "2024-07-23T13:42:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![finlaydotb](https://ziggit.dev/user_avatar/ziggit.dev/finlaydotb/32/3462_2.png) [@finlaydotb](https://ziggit.dev/u/finlaydotb)\
**Post date:** [July 23, 2024, 1:42pm UTC](https://ziggit.dev/t/what-is-root-zig/5319/1 "2024-07-23T13:42:48Z")

</div>

When I `init` a new project, a `root.zig` file is also created.

What is the `root.zig` file? Can I remove it? if so why is it even generated by default.

I unfortunately could not find any place where this is documented.

---

<div class="post-metadata">

**Author:** ![IntegratedQuantum](https://ziggit.dev/user_avatar/ziggit.dev/integratedquantum/32/782_2.png) [@IntegratedQuantum](https://ziggit.dev/u/IntegratedQuantum)\
**Post date:** [July 23, 2024, 2:06pm UTC](https://ziggit.dev/t/what-is-root-zig/5319/2 "2024-07-23T14:06:48Z")

</div>

`zig init` creates a project that can be used both a library (→`root.zig`) and an executable(→`main.zig`).  
So if you only need the executable you can safely remove `root.zig`.

---

<div class="post-metadata">

**Author:** ![finlaydotb](https://ziggit.dev/user_avatar/ziggit.dev/finlaydotb/32/3462_2.png) [@finlaydotb](https://ziggit.dev/u/finlaydotb)\
**Post date:** [July 23, 2024, 2:24pm UTC](https://ziggit.dev/t/what-is-root-zig/5319/3 "2024-07-23T14:24:21Z")

</div>

> `zig init` creates a project that can be used both a library (→`root.zig`)

Interesting. I would have expected that to be named `lib.zig`

---

<div class="post-metadata">

**Author:** ![Calder-Ty](https://ziggit.dev/user_avatar/ziggit.dev/calder-ty/32/10237_2.png) [@Calder-Ty](https://ziggit.dev/u/Calder-Ty)\
**Post date:** [July 23, 2024, 3:15pm UTC](https://ziggit.dev/t/what-is-root-zig/5319/4 "2024-07-23T15:15:21Z")

</div>

I think it’s convention. You could name it anything, you’d just need to update the `root_source_file` parameter in the build.zig. I don’t think there is anything “special” with root.zig files ala `mod.rs` in rust
