12 ms·
> Zig is C-like Only in the sense that the language is simple and small, but C pays for that by being inexpressive (you can find families of C++ programs for w
by pron 3y ago
> Zig is C-like
Only in the sense that the language is simple and small, but C pays for that by being inexpressive (you can find families of C++ programs for which an equivalent C program would require exponentially more code). Zig, on the other hand, is small and simple while being just as expressive as C++. It achieves that through a remarkable observation: many primitive features can be avoided with a powerful enough compile-time computation mechanism with introspection.
Zig is so revolutionary in its design that it's hard to compare it to anything else. Or, put another way, any comparison is sure to miss out on some very foundational piece. So yes, in some sense Zig is like C (simple, low-level), but it's as expressive as C++. In another sense, Zig is like Scheme (minimalistic elegance), and yet it feels familiar and it does not rely on macros for its core power. In other ways it's like Go (easy to learn, easy cross-compilation), but it gives full control and is more flexible.
At this point, Zig is sui generis.
- 1980phipsi 3y ago> Zig is so revolutionary in its design that it's hard to compare it to anything else. I mean, Zig has an interesting combination of functionality, but I wouldn't say that the individual pieces are revolutionary. Who knows though, the whole could be more revolutionary than the sum of it's parts...
- ngrilly 3y agoZig's take on comptime is quite new (which is the main point of the article being discussed). Error handling and async/await as well.
- 1980phipsi 3y agoZig's take on comptime is slightly different from C++ and D, but that doesn't make it revolutionary. It has first class types, which allows you to pass them to a function along with normal function parameters, instead of having a separate syntax for it like C++ and D. But it's not really new.
- pron 3y agoThat's a little like saying that smartphones weren't really new because we had mobile phones and calculators and cameras and video cameras and handheld games before. Zig's comptime is revolutionary and really new in that it replaces many other separate features and is the basis of Zig's minimalism. Figuring out how to discard features is much more difficult than adding them, and simplicity is something that's impossible to add once it's lost. The message is not the existence of a rather general compile time execution, but that with a particular design of such a mechanism you can do away with other things.
- deleted 3y ago[deleted]
- pron 3y agoTo say something truly original you don't have to invent new words.
- LAC-Tech 3y agoIt's the only mainstream language I know where structs and modules are the same thing.
- Sharlin 3y agoYeah, I had written something like "Zig is pretty much designed around the comptime system" at first, should've probably kept it :D
- jandrewrogers 3y agoThe unapologetic embrace of compile-time metaprogramming in a clean model drives most of my interest in Zig. I use metaprogramming heavily in C++ to dramatically reduce code size and increase type safety. Contrary to popular assumption, in C++20 metaprogramming is relatively concise, tidy, and maintainable, unlike the eldritch horror that was metaprogramming in C++11. But I don't think anyone would describe it as elegant or designed. I haven't had time yet to try porting C++ metaprogramming to Zig in order to see what is possible. Most other systems-y languages have a much weaker metaprogramming story than C++. Many developers underestimate the importance of metaprogramming in systems languages for ensuring quality and security. Defects scale proportional to the lines of code. Strong metaprogramming facilities can reduce the lines of code required several-fold.
- gpderetta 3y agoC++11 gave us variadics which opened a new metaprogramming world. For true horror try cons-based typelists in C++98.