Live data from Hacker News

Zig cc: A drop-in replacement for GCC/Clang (2020)

andrewkelley.me

21–30 of 126 posts

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#21
post #6

I really like what they've done for cross-compilation. Automatically selecting appropriate libc/crt implementation is such a relief. Compared to Zig, cross-compilation in C/C++/Rust seems downright user-hostile: you have to obtain the correct cross-sdk, but it won't tell you which one, or how to get it (some combos don't even exist), or even where to put it. If you don't guess everything correctly, it will fail with…

I would not include Rust in that list, in my experience rustup and cargo are miles ahead of C/C++ when cross compiling.

[deleted]

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#22
From Release Note 0.8 Roadmap [1],

>The major theme of the 0.9.0 release cycle will be stabilizing the language, creating a first draft of the language specification, and self-hosting the compiler.

So I am guessing we could see 1.0 release within 12 months time? Or will there be 0.10 or 0.11 after that?

I am just eager to hear people's comments and opinions for using it in production within their context and edge cases.

And as a sort of side note, I quite like the momentum and the way Andrew has been handling Zig's PR. I just hope and pray HN keep that tradition, dont over hype it.

[1] https://ziglang.org/download/0.8.0/release-notes.html#Roadma...

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#23
post #14

I’ve been learning Zig for a few months now and what I’m in love with is the ability to just use Zig to interact with whatever C libraries I want, but doing so with the conveniences that Zig offers. I want to use SDL2 and cairo and pango? No problem! GTK4, easy peasy! There’s a C lib that comes as a single .c file that makes it easier to interact with SDL? Drop it on the project folder and compile it with Zig along a…

Note that none of autotools, make, and valgrind are required for C. You could be building with meson and ninja.

Valgrind is also more useful than just for C, although admittedly it's most useful for binaries that have parts written in unchecked languages like C.

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#24
post #19
post #6

I really like what they've done for cross-compilation. Automatically selecting appropriate libc/crt implementation is such a relief. Compared to Zig, cross-compilation in C/C++/Rust seems downright user-hostile: you have to obtain the correct cross-sdk, but it won't tell you which one, or how to get it (some combos don't even exist), or even where to put it. If you don't guess everything correctly, it will fail with…

I don't know much about cross compilation, but in terms of the Rust case, could part of it be the relative complexity of the language compared to Zig?

`zig cc` cross-compiles C, not Zig.

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#25
post #24
post #19

Earlier quoted context omitted.

I don't know much about cross compilation, but in terms of the Rust case, could part of it be the relative complexity of the language compared to Zig?

`zig cc` cross-compiles C, not Zig.

No but I mean why the Zig cross compilation story is better than Rust according to this thread

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#26
post #14

I’ve been learning Zig for a few months now and what I’m in love with is the ability to just use Zig to interact with whatever C libraries I want, but doing so with the conveniences that Zig offers. I want to use SDL2 and cairo and pango? No problem! GTK4, easy peasy! There’s a C lib that comes as a single .c file that makes it easier to interact with SDL? Drop it on the project folder and compile it with Zig along a…

As much as I dislike C from safety point or view, all of that is also easy peasy with C.

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#27
post #6

I really like what they've done for cross-compilation. Automatically selecting appropriate libc/crt implementation is such a relief. Compared to Zig, cross-compilation in C/C++/Rust seems downright user-hostile: you have to obtain the correct cross-sdk, but it won't tell you which one, or how to get it (some combos don't even exist), or even where to put it. If you don't guess everything correctly, it will fail with…

> cross-compilation in C/C++/Rust seems downright user-hostile: you have to obtain the correct cross-sdk, but it won't tell you which one, or how to get it (some combos don't even exist), or even where to put it.

Since advent of multiarch, crosscompilation does not seem harder than regular compilation. Just install package with gcc for target arch and required libraries for target arch (using the same way as gcc and libraries for host arch).

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#28
post #22

From Release Note 0.8 Roadmap [1], >The major theme of the 0.9.0 release cycle will be stabilizing the language, creating a first draft of the language specification, and self-hosting the compiler. So I am guessing we could see 1.0 release within 12 months time? Or will there be 0.10 or 0.11 after that? I am just eager to hear people's comments and opinions for using it in production within their context and edge cas…

> So I am guessing we could see 1.0 release within 12 months time? Or will there be 0.10 or 0.11 after that?

1.0 is going to take a lot longer than that.

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#29

`zig cc` is also amazing to compile C and C++ code to WebAssembly. For standalone WebAssembly or WASI. No need to install yet another toolchain, this is just another target Zig can compile to, out of the box.

Actually you can do the same with clang.

Emscripten just installs a bunch of stuff to make it easier to use existing libraries.

If you just want to use standard library, no need for extra stuff.

https://surma.dev/things/c-to-webassembly/

Re: Zig cc: A drop-in replacement for GCC/Clang (2020)

#30
post #25
post #24

Earlier quoted context omitted.

`zig cc` cross-compiles C, not Zig.

No but I mean why the Zig cross compilation story is better than Rust according to this thread

I see. I'll let the real experts add some insight but I don't think language complexity has much to do with it, considering Rust compiles to an IR first anyway. And I would say Rust has a good cross-compilation story as it is. In 2016 (!) I managed to get Rust to compile my SDL2 game to a mipsel device that used a custom GCC toolchain (http://www.gcw-zero.com/develop)
Post reply on HN