←back to thread

Zig is hard but worth it

(ratfactor.com)
401 points signa11 | 4 comments | | HN request time: 0.944s | source
Show context
ldelossa ◴[] No.36150624[source]
I'm surprised that the reason I'm mostly interested in Zig is not mentioned.

This is C interop.

I work with C quite a bit and I enjoy it, however writing a large project in C can be tiresome.

Having an option like Zig which can import C headers and call C functions without bindings is pretty attractive, especially when you want to write something a big larger but still stay in C world.

replies(6): >>36151152 #>>36151354 #>>36151700 #>>36153013 #>>36153780 #>>36158610 #
1. ziml77 ◴[] No.36151354[source]
The thing that's espcially nice about that interop is that Zig includes its own C compiler. That eliminates the pain of having a build script locate an installed C compiler and figure out what options should be passed to it.
replies(1): >>36156867 #
2. lost_tourist ◴[] No.36156867[source]
Why would I use zig c compiler in place of gcc or clang? Mainly for zig interactivity or does it have some advantage other than that over the aforementioned compilers?
replies(1): >>36156986 #
3. TUSF ◴[] No.36156986[source]
Zig's C/C++ compiler is just clang, but with header files for most major platforms included, and sane defaults, so there's no hassle getting it it to cross-compile. Some companies have been using Zig solely for an easier to use clang.
replies(1): >>36157078 #
4. lost_tourist ◴[] No.36157078{3}[source]
Ah I see, thanks for your answer!