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…
Zig cc: A drop-in replacement for GCC/Clang (2020)
31–40 of 126 posts
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#32I 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…
It's always a bit harsh comparing a 36 year old language with more-or-less full backwards compatibility, with a new language designed with the benefit of hindsight. That's not to say that it's impossible to do something like that in a C++ compiler but it's going to be more work than there is benefit. Tangentially related: https://twitter.com/__phantomderp/status/1416108650809241601 C++ also tries to bring in modern p…
For example, move semantics are a peg leg for the octopus. Should an octopus have a peg leg? I'm not a biologist of any sort, but my guess is "No". I can see why C++ wanted to add move (without this performance in some scenarios is just awful) and yet since C++ didn't start out having move semantics and can't give up backward compatibility it has to shoehorn them in with this awkward "hollowed out object" idea. The result is performance still isn't where it could be and the feature is unergonomic.
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#33Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#34It does look impressive! Does anyone know if Zig exposes some APIs to extract/manipulate/analyze the AST of the C program? It might be a nice alternative to LLVM, which I find a little overwhelming.
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#35I’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.
If you can't afford the virtualisation overhead, and you need to find leaks you should try what Raymond Chen suggests in "The poor man's way of identifying memory leaks" (not bothering to link since Microsoft will only move it anyway, they have several times since I read it). If you are too lazy to do it by hand, or find the technique works but wish it less manual, this is what Leakdice does:
https://github.com/tialaramex/leakdice OR https://github.com/tialaramex/leakdice-rust
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#36I’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…
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#37I’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…
Omg, skip the rest but valgrind is amazing and requires almost zero learning to use. Build your code with debug symbols, find inputs that trigger a segfault, then run it under valgrind. It then reports out of bounds memory access, with a full stacktrace. It's got a billion more uses, but at the most basic, that one use-case will keep you from wasting time futzing with a debugger or print-debugging 99% of segfaults an…
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#38I 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…
What this kind of stories always miss is that the host platform needs all system libraries for the target platform for anything beyond the basic examples using the standard library. E.g. try to cross compile Metal shading example for iOS from Linux with zig, or do a Win2D UWP rendering application from Linux with zig.
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#39It does look impressive! Does anyone know if Zig exposes some APIs to extract/manipulate/analyze the AST of the C program? It might be a nice alternative to LLVM, which I find a little overwhelming.
zig cc uses LLVM under the hood.
Re: Zig cc: A drop-in replacement for GCC/Clang (2020)
#40Earlier quoted context omitted.
I would not include Rust in that list, in my experience rustup and cargo are miles ahead of C/C++ when cross compiling.
Personally, I see it in three tiers: Rust improved upon those experiences, but I still wish someone would implement what Zig has in rustc.