Whoa, I’ve been referred to as “a C developer”… I’m not sure if I deserve that qualification!
Overall a pretty good overview of Zig! One small thing,
A distinctive feature of Zig is that it does not deal with memory allocation directly in the language. There is no malloc keyword like in C/C++.
Well C++ does has the new operator, but malloc is part of the C standard library. I think I understand the author’s intent though: Zig doesn’t have a global allocator. This is something I’ve been thinking about a lot lately. The more I use Zig the more I appreciate the convention of explicit allocators passed to functions. It makes heap allocations very clear in code, and it has made it very easy for me to confidently write an allocation-free fuzzy finding Zig module while still relying on the standard library.
Note that it’s not a port, but instead a Zig Allocator wrapper around the C library. The Zig compiler is also a C compiler and can import C headers natively which is pretty neat nonetheless.
Zig is a very cool language. I don’t think I’ll use it for a while - I really enjoy Rust and don’t feel the need for a new language right now - but I’m glad to see that this “next gen” of languages is so much better than the last. Python, C, Java, Go - absolute trash tier languages. The newer languages cropping up like Zig, Rust, Nim, and others seem infinitely better built/ have learned from previous mistakes.
“Trash tier” is a bit harsh, especially since these are very popular languages with lots of developers using them. It’s ok to have favorites, but there’s no need to diminish what other people use with such language.
Go is very much from the same era as Zig and Rust. While it’s not my favorite language, one area where it really excels is all of the tooling and community around the language. Makes up for a lot of its shortcomings (and clearly a lot of developers agree).
Whoa, I’ve been referred to as “a C developer”… I’m not sure if I deserve that qualification!
Overall a pretty good overview of Zig! One small thing,
Well C++ does has the
new
operator, butmalloc
is part of the C standard library. I think I understand the author’s intent though: Zig doesn’t have a global allocator. This is something I’ve been thinking about a lot lately. The more I use Zig the more I appreciate the convention of explicit allocators passed to functions. It makes heap allocations very clear in code, and it has made it very easy for me to confidently write an allocation-free fuzzy finding Zig module while still relying on the standard library.Could one create a custom allocator that does garbage collecting for you?
I do not know much about garbage collection in general so I do not know if this is a stupid question. :P
Yes! Not a stupid question. This has been done in C, a well-known example being the Boehm-Demers-Weiser garbage collector which has already been ported to Zig here: https://github.com/mitchellh/zig-libgc
Note that it’s not a port, but instead a Zig Allocator wrapper around the C library. The Zig compiler is also a C compiler and can import C headers natively which is pretty neat nonetheless.
Oops that’s right, thank you for the correction!
That’s really cool! Thanks.
Zig is a very cool language. I don’t think I’ll use it for a while - I really enjoy Rust and don’t feel the need for a new language right now - but I’m glad to see that this “next gen” of languages is so much better than the last. Python, C, Java, Go - absolute trash tier languages. The newer languages cropping up like Zig, Rust, Nim, and others seem infinitely better built/ have learned from previous mistakes.
“Trash tier” is a bit harsh, especially since these are very popular languages with lots of developers using them. It’s ok to have favorites, but there’s no need to diminish what other people use with such language.
@insanitybit insulted those languages, not the developers who use them or what they use them to make.
Still a too harsh comment.
Go is very much from the same era as Zig and Rust. While it’s not my favorite language, one area where it really excels is all of the tooling and community around the language. Makes up for a lot of its shortcomings (and clearly a lot of developers agree).