3 ms·
I have been playing around a lot with Zig lately, and though it's still in beta, it really feels like it has the best chance at being a true C successor. While
by Zambyte 2y ago
I have been playing around a lot with Zig lately, and though it's still in beta, it really feels like it has the best chance at being a true C successor. While Rust feels like they started with C++ and worked on making it harder to write incorrectly, Zig feels like they started with C and worked on making it easier to write correctly.
They also have a few pillars that they call the "Zen" of Zig[0], of which three out of the first five are directly related to readability.
[0] https://ziglang.org/documentation/0.14.0/#Zen https://ziglang.org/documentation/0.14.0/#Zen
- voidUpdate 2y agoI really want to start trying to learn zig, but right now I feel like it's not quite finished enough. When it hits 1.0, I'll probably give it a more serious look
- woodrowbarlow 2y agoZig is friendly for soft-transitions because the compiler can compile C code. you can use Zig tooling for a C codebase, and then slowly add Zig code where it makes the most sense.
- voidUpdate 2y agoWell I was debating learning C this year, but Zig seems like the more attractive option. I'd be starting new projects from scratch
- johnisgood 2y agoI think it is still useful to learn C, however. For personal projects you could use Zig, but it is still good to know C. C is like the lingua franca of programming languages, and some assembly (if you care about optimization, for example).
- woodrowbarlow 2y agoahh, ideally i'd say learning them in any order is fine but unfortunately since the zig ecosystem is not mature yet that means you'll find yourself using C libraries from zig fairly often. so, yes, i agree learning zig is a great idea for new independent projects but (at the current stage) be prepared to also learn at least enough about C to use C libraries (return type conventions, raw enums, c-style strings, inflexible allocators).
- Arch-TK 2y agoI used to think rust was like C++ but harder to write badly but I don't think it's anything like C++ now that I've spent a couple of years writing it. Rust is its own thing, it has none of the extensive baggage of C++, and doesn't appear to be set to reach that level of baggage at any point in time soon if ever. It's a much cleaner, clearer, and easier to reason about programming language.
- Zambyte 2y agoThe lack of baggage is definitely a huge improvement, but I believe Zig also has this advantage over C. Rust and C++ also seem to encourage a similar style of programming (particularly newer C++), and so do Zig and C. The former encourages creating a library of types with inheritance, using syntactic sugar where applicable (ie operator overloading), and a functional style, whereas the latter limits the programmer to simple compound types without inheritance (manual, explicit dispatching), obvious syntax, and an imperative style. Both seem to have their place in the ecosystem to me, but I'm really excited to see Zig mature.
- shepmaster 2y ago> [Rust and C++] encourages creating a library of types with inheritance You'll want to expand on and clarify your meaning here, as Rust does not have inheritance.
- Zambyte 2y agoTraits encourage the same programming style, regardless of if it's technically inheritance or not.
- Arch-TK 2y agoI disagree completely. It's not just a technicality, traits are not the same as multiple inheritance. They allow you to solve the same kinds of problems but traits don't introduce the mountain-loads of confusion, complexity and headache that multiple inheritance does. Moreover, nothing forces you to use traits. You're just strictly better off using them in many cases. But you can always defer to writing overtly repetitive C style code if you want.