I'll tell you why. The first feature mentioned on the home page is
> Manual memory management. Memory allocation failure is handled correctly. Edge cases matter!
Of course, not getting to the edge case in the first place is paramount, yet Zig offers no (option) GC, no borrower, no RAII scheme, no nothing.
Because the docs are very clear on this: http://ziglang.org/documentation/master/#memory
:D
The problem is that there really isn't any replacement for C/C++. There have been a lot of new languages in the last two decades, but nobody has been making a real C replacement. People mostly make higher level languages, usually relying on garbage collection.
I have seen some projects starting up now that aim at actually replacing C, but it will take a decade for them to mature.
https://www.rust-lang.org/en-US/ (I'm not sure I would consider Rust a C replacement though. C can be compiled with a pretty simple, dumb compiler, while I think Rust requires quite an advanced compiler. A real C replacement should be simple, even at the expense of safety)
You could also wonder if we will use languages relying on garbage collection for future embedded applications. The problem now is not processing speeds. Cheap microcontrollers are starting to hit 100Mhz+. But memory is still quite restricted. On-chip SRAM is expensive, so you really want to be careful with dynamic memory use. However, if we get large, fast, cheap on-chip RAM in the future, maybe we'll start using languages like D, Go or Nim for embedded applications.
It does have defer
:
http://ziglang.org/documentation/master/#defer
So it's better than standard C for freeing memory. That said I think defer
undermines their ideology somewhat of not calling functions implicitly. If defer
within a function is sufficient to allow implicit function calls at the end of scope, so would $macro()
expansion syntax be. If they don't want RAII, I think Rust-style macros would add a lot of power.
Check out Zig! It's still in active development, but it's already looking very good. It's a much smaller language, definitely closer to C but with all the sharp corners rounded.
Zig comes to mind. Very interesting project, definitely keep an eye on it. I like Rust better because I think that the ownership system protects me more than it hampers me, but I love the philosophy of Zig.
Tangent:
Wow I noticed you have a C preprocessor and C grammar in the lib/
dir! That is pretty awesome!
I would love something like for my shell, because shell is a language meant to glue things together. And sometimes byte streams aren't the right way to do it (although they are more often than most people think.)
I was thinking of providing a helper to link libclang. And then maybe serializing a subset of it to ASDL. Zig does this:
https://github.com/zig-lang/zig/blob/master/src/parsec.cpp
That way it can handle C++ too. But your approach is very interesting. I started looking at your blog and there is a ton of interesting stuff there.
I'm still looking at RPython... my inclination is not to use it but I don't exactly have a crisp reason why. I think it is the fact that I don't understand the performance model. And I don't understand memory layout and interfacing with C code in RPython.