Hacker News new | ask | show | jobs
by andrewfromx 960 days ago
zig does seem like a much more reasonable c/c++ replacement than rust.
5 comments

Agreed. It even brings all of the use after frees, memory overflows, data races etc. along so C/C++ programmers will feel right at home!
Yes, Zig is friendly to C/C++ programmers. This is a big advantage of Zig.
And we'll keep building the systems that power the world so you can continue to feel right at home. You're welcome!
So life critical software will continue to have completely avoidable bugs in it, got it.
it is possible to write bug free code in many compiled languages
This is just simply not so, or at best, the odds of writing a nontrivial bug free program in any language are negligible. Also, we are talking specifically of C, C++, and Zig here. Three compiled languages among hundreds.
Only if your name is Knuth--put your money where your mouth is.
i enjoyed this laugh, thank you
But nobody does?
It's a job security thing. Otherwise you deliver the perfect program and then there's no need for you anymore.
There's a lot to like about Zig, especially related to metaprogramming. Unfortunately, bulletproof memory safety is table stakes for a modern language. Without a garbage collector or borrow checker, Zig is DOA for any use case that involves untrusted data.

Maybe there's a few niches (single player games?) that don't need memory safety...

You can always use a garbage collecting allocator with Zig, if you're that paranoid anout it.
For that better use D, Nim, Swift, C#, Go, designed from the ground up with one in mind, and whole ecosystem counts on it, instead of having coloured libraries.
By convention, all Zig libraries have functions that take an allocator as input from the user. Your application can use libgc[1] and pass the allocator to any library function you use, and not worry about deallocating afterwards.

[0]: https://github.com/linusg/zig-libgc

You missed the part of ecosystem designed with a GC in mind.
Does an ecosystem designed with custom allocators (including gc) in mind not count for anything?
The distinction I’ve heard is that Zig is a “better C” and Rust is a “better C++.” I haven’t done a lot of programming in any of these languages, but as an outsider it certainly seems apt.
These can be true, while at the same time, “Rust is a better C.”

Zig and Rust have a lot of the same and a lot of different stuff to offer. I drank the Rust koolaid, but I thought for a long time Zig or Nim would be the most popular C alternative.

It’s all about the macros, it seems. Rust’s macros are not the best in the world, but they are really good.

That's not a good analogy. Zig shares much blood with C, but Rust doesn't share much blood with C++. Though, from the complexity view, Rust can be viewed as another C++ (or C+++).
While it offers Modula-2 like safety, with a syntax more appealing to C developers, in the 21st century we expect a little more from a systems language.
Reasonable and memory unsafe. Pick one.