5 ms·
Can anyone with more experience/understanding of Zig give an elevator pitch about why and when I would use Zig? I love the concept of a low level language that'
by sephware 8y ago
Can anyone with more experience/understanding of Zig give an elevator pitch about why and when I would use Zig? I love the concept of a low level language that's not C, but the home page doesn't paint a clear picture to me about what its strengths are and in what situations it really shines, and what trade-offs it makes to get there.
- MaxBarraclough 8y agoI don't know of an 'objective' thorough evaluation of Zig as it stands, but I hope these are of interest: Previous HackerNews discussion on Zig: https://news.ycombinator.com/item?id=17184407 https://news.ycombinator.com/item?id=17184407 Also, perhaps not as objective as you'd like but still good resources: Whirlwind tour of the basic thinking behind Zig: https://andrewkelley.me/post/intro-to-zig.html https://andrewkelley.me/post/intro-to-zig.html A ~50 minute talk on Zig, by its creator: https://www.youtube.com/watch?v=Z4oYSByyRak https://www.youtube.com/watch?v=Z4oYSByyRak
- jeremycw 8y agoThe short of it is C without the warts plus a few small quality of life improvements. The long of it: The competition right now in this space as I see it is: C, Rust, C++. Even C++ doesn't fully fit because you have to turn off language features like exceptions to have the guarantees you need for systems programming. So in turn. C hasn't really changed in 40 years so all it's warts are still intact and has specific pain points that will never be addressed. C++ conversely has added every language feature plus the kitchen sink over the past 30 years. People say: "Just don't use the features you don't want", but that is unrealistic when you have to interoperate with third party libraries etc. If you have to drop a large portion of the C++ ecosystem to use the subset of the language you like then you've lost a major benefit of choosing C++ in the first place. Rust, while being more thoughtful about it than C++, has provided a large set of features to work with. It is a much bigger language than C. It's also taken a very opinionated stance on safety with the borrow checker which causes a large learning curve and a lot of mental overhead. Finally Zig is an attempt to be more safe than C where it can without being as overbearing as Rust. Add just the necessary features that a huge boost to quality of life while not flooding the programmers mental model of the language. I think of it as kind of a C+.
- rapsey 8y agoRust's borrow checker does not have a lot of mental overhead while working once you are moderately proficient. It imposes design constraints that in the end work out for the better. This is why Rust users are so fanatical about it.
- foldr 8y agoThis is only true in cases where a single ownership model makes sense. In cases where it doesn't, there is a definite overhead. I think even the strongest Rust advocates would not deny the existence of this overhead. They'd just point out that you'd have the same overhead in C++, but without the compiler helpfully telling you when you've made a mistake. I'd also add that there are (small) warts on Rust's current implementation of borrow checking which everyone agrees are minor annoyances, even to experienced users: https://github.com/rust-lang/rust/issues/43234 https://github.com/rust-lang/rust/issues/43234 Judging by that issue thread, some of these issues are about to be fixed.
- jeremycw 8y ago> It imposes design constraints that in the end work out for the better. I feel the jury is still out on this. It does impose design constraints that remove a certain subclass of errors, whether this correlates to actually causing better designed programs in the sense of readability, maintainability, etc. I'm unsure. I understand the desire for this to be true and I feel that some of the fanaticism around the language is the belief that this is true. Developers like to have the 'one true way' to solve problems. Go's popularity I feel is in part because of this as well but achieved it by having a bare bones language with less options instead of a restrictive compiler. If you take the 'restrictive compiler' argument to its logical conclusion for a program that accepts input x and produces output y there would only be one valid way to code this program. This would be good in the sense that presumably the compiler has proven that your program works and is correct. On the other hand though I have no inclination to believe that this program would be the most understandable, modifiable way to get from x -> y.
- sephware 8y ago