The reason I really like Zig is because there's finally a language that makes it easy to gracefully handle memory exhaustion at the application level. No more praying that your program isn't unceremoniously killed just for asking for more memory - all allocations are assumed fallible and failures must be handled explicitly. Stack space is not treated like magic - the compiler can reason about its maximum size by exam…
I don't know Zig. The article says "Many people seem confused about why Zig should exist if Rust does already." But I'd ask instead why does Zig exist when C does already? It's just a "better" C? But has the drawback that makes C problematic for development, manual memory management? I think you are better off using a language with a garbage collector, unless your usage really needs manual management, and then you ca…
Thoughts on Go vs. Rust vs. Zig
581–590 of 599 posts
Re: Thoughts on Go vs. Rust vs. Zig
#582Earlier quoted context omitted.
template concept non_zero = (V != 0); template concept arithmetic = std::is_arithmetic_v ; template requires non_zero struct complicated { template using nested_alias = std::tuple ..., std::conditional_t 0 && ...), T, std::nullptr_t> >; template static constexpr auto process() { return [] (std::index_sequence ) { return nested_alias {}; }(std::make_index_sequence {}); } }; I most definitely agree.
The difference is that nobody really writes application code like that, it's a tool for writing libraries and creating abstractions. If all of the ugliness of async Rust was contained inside Tokio, I would have zero problems with it, but it just infects everything it touches
Re: Thoughts on Go vs. Rust vs. Zig
#583I could never get into zig purely because of the syntax and I know I am not alone, can someone explain the odd choices that were taken when creating zig? the most odd one probably being 'const expected = [_]u32{ 123, 67, 89, 99 };' and the 2nd most being the word 'try' instead of just ? the 3rd one would be the imports and `try std.fs.File.stdout().writeAll("hello world!\n");` is not really convincing either for a ba…
'const expected = [_]u32{ 123, 67, 89, 99 };' constant array with u32, and let the compiler figure out how many of em there are (i reserve the right to change it in the future)
Re: Thoughts on Go vs. Rust vs. Zig
#584The last paragraph captures the essence that all the PL theory arguments do not. "Zig has a fun, subversive feel to it". It gives you a better tool than C to apply your amazing human skills, freely, whereas both Rust and Go are fundamentally sceptical about you.
I mean, if we're going to go there, you could take it a step further: Zig allows the programmer ego to run wild in a way that Rust and Go do not. This is perhaps somewhat natural; people like and want to be good at things . Where you fall on the trade off is up to you.
Re: Thoughts on Go vs. Rust vs. Zig
#585>You have more control here than you have even in C: To allocate bytes, you have to call alloc() on a specific kind of allocator You can write your own allocator in C. You don't have to use malloc.
Re: Thoughts on Go vs. Rust vs. Zig
#586> Many people seem confused about why Zig should exist if Rust does already. It’s not just that Zig is trying to be simpler. I think this difference is the more important one. Zig wants you to excise even more object-oriented thinking from your code. I feel like Zig is for the C / C++ developers that really dislike Rust. There have been other efforts like Carbon, but this is the first that really modernizes the langu…
Same. Zig's niche is in the vein of languages that encourages using pointers for business logic. If you like this style, Rust and most other new languages aren't an option.
Re: Thoughts on Go vs. Rust vs. Zig
#587Earlier quoted context omitted.
It'd be very interesting to see an OO language that passes around allocators like zig does. There is definitely nothing in the concept itself that stops that.
What about allocators in C++ STL (Standard Template Library)? Honestly, I have been reading & writing C++ for a squillion years, and (1) I have never used an allocator myself, and (2) never seen anyone else use it. (Granted, I have not seen a huge number of enterprise C++ code bases.)
Re: Thoughts on Go vs. Rust vs. Zig
#588Earlier quoted context omitted.
Same. Zig's niche is in the vein of languages that encourages using pointers for business logic. If you like this style, Rust and most other new languages aren't an option.
This confuses me. In zig null pointers are illegal, and I have yet to run into any case that should be addressed by using pointer arithmetic, that's all taken care of with slices.
Re: Thoughts on Go vs. Rust vs. Zig
#589Earlier quoted context omitted.
It'd be very interesting to see an OO language that passes around allocators like zig does. There is definitely nothing in the concept itself that stops that.
What about allocators in C++ STL (Standard Template Library)? Honestly, I have been reading & writing C++ for a squillion years, and (1) I have never used an allocator myself, and (2) never seen anyone else use it. (Granted, I have not seen a huge number of enterprise C++ code bases.)
arena allocators are necessity for high performance software, because heap allocations are magnitude slower.
Re: Thoughts on Go vs. Rust vs. Zig
#590Earlier quoted context omitted.
> Every adherent of managed memory languages should take it as a personal insult that people are choosing to write modern terminal emulators in Rust and Zig. How so? Garbage collection has inherent performance overhead wrt. manual memory management, and Rust now addresses this by providing the desired guarantees of managed memory without the overhead of GC. A modern terminal emulator is not going to involve complex r…
> How so? Garbage collection has inherent performance overhead wrt. manual memory management, and Rust now addresses this by providing the desired guarantees of managed memory without the overhead of GC. I somewhat disagree, specifically on the implicit claim that all GC has overhead and alternatives do not. Rust does a decent job of giving you some ergonomics to get started, but it is still quite unergonomic to fix…
all GC have overhead, but specific allocation pattern: allocators with arena has as minimum overhead as possible, and are orders of magnitude faster because of this. Feel free to tell why this statement is wrong.