4 ms·
Does Zig fit your bill?
by accelbred 2y ago
Does Zig fit your bill?
- sylware 2y agoDunno, I should have a look though. But I have recollection of some garbage collector, wrong/right ?
- nick__m 2y agoI doubt that, zig is allocators land. Even stdlib datastructures required an allocators to be instanciated. Have a look at the selection of allocators: https://zig.guide/standard-library/allocators https://zig.guide/standard-library/allocators .
- sylware 2y agoI had a look, zig seems to require a runtime, even small, for basic syntax support. So it seems it is not suitable. You should be able to generate machine code without the need of any runtime, like you can with C.
- mlugg 2y agoI'm unsure what you're referring to here -- Zig doesn't have any runtime, it doesn't even depend on libc. The only thing I can think of that you might be referring to is compiler-rt: if so, this is a thing in C too! It's just a small collection of implementations for operations the code generator wants to call into (e.g. memset, arithmetic for integers larger than CPU word size). Clang uses compiler-rt when compiling C code, and GCC's equivalent is libgcc. Nonetheless, Zig lets you disable it using `-fno-compiler-rt`, in which case you'll need to provide the relevant symbols yourself somehow.
- sylware 2y agoThis is not what I understood, there is some kind of flags required for pointers or something, which requires a data section for basic primitive types.
- mlugg 2y agoI'm afraid I'm not sure what you're referring to. For instance, I can build a simple Hello World in Zig using `zig build-exe`, and get a static executable, on which I can use `nm` to confirm that there aren't symbols from any kind of runtime. I can even trivially build the actual Zig compiler to a static binary. (For context, by the way, I'm on the Zig "core team"; I'm a notable contributor to the project.)
- sylware 2y agommmmh... basically, generates machine code which only requires a stack (which could be used by code paths not written in zig), contained in memory pages with execute and read permission only. Ofc this machine code would interact with the other machine code (written in other languages) via the architecture calling convention (the ABI/C one).
- accelbred 2y agoThats what Zig does. It compiles down to the same stuff as C. It does not have a runtime.
- butterisgood 2y agoIt also has been very much trying to get rid of things like "undefined behavior".