4 ms·
It's another "C but better" language. Contrasted with some of the other solutions in that space, it has an emphasis on stability (once 1.0 is released) and simp
by hansvm 6y ago
It's another "C but better" language. Contrasted with some of the other solutions in that space, it has an emphasis on stability (once 1.0 is released) and simplicity -- eliminating low hanging fruit in terms of undefined behavior and whatnot, but not significantly hampering expressiveness or requiring excessive syntactic contortions to go the last mile and make it completely safe.
- blackrock 6y agoSo.. never? I’m of the impression that C will never die.
- dnautics 6y agoYou should try zig. You'll never want to go back, and the c interop is so good, it's easy to kill the c code over time using embrace extend extinguish.
- jorangreef 6y agoAs someone who loves C, Zig has replaced C for me and I don't plan to go back. There are just too many benefits, not least developer velocity and readability. Zig is also very approachable to anyone who is familiar with TypeScript, in a way that C isn't. This means more of your team can get excited and get involved, at least in terms of reading the code. And with Zig, where you have to spend a little extra maintenance time paying for the language being pre 1.0, that's still nothing compared to the upfront and long-lived costs associated with C. You can develop so much faster in Zig compared to C, that you're ahead even pre 1.0.
- yellowapple 6y agoTo expand on this a bit: I feel like learning Zig has helped me better understand C, particularly when it comes to allocation and pointers. Zig has more facilities to specify the intent behind a lot of the common C programming concepts, which has helped make things "click" in both languages.
- blackrock 6y agoI do like Zig’s import construct. const print = @import("std").debug.print; I’m looking for a new systems programming language. For all the hype of Rust, I don’t think this is it. How does Zig compare to Nim? Does Zig have a future in games programming? I feel games programming is the ultimate test, to validate the true success of a programming language. I do like that Zig compiles to LLVM. Although this in itself will exact a minor performance penalty, in exchange for wider CPU coverage. Nim transpiles its code down to C, and I’m not certain how that will play out. As you’re now writing your new language on an already somewhat buggy language. But this does give Nim the possible speed advantage, of getting the code compiled closer to the metal, whereas Zig will compile to the intermedia LLVM layer.
- dnautics 6y ago> I do like that Zig compiles to LLVM It's going to start compiling to zig IR soon (if it doesn't already), and zig IR will be translated to LLVM IR or fed into zigc. So I think the recommended development cycle will be - use zigc for fast iteration on localdev, then when releasing, use slower LLVM for extra optimization passes and also for cross-compilation. > gamedev I think the highest interest in zig is currently gamedev, but there are SO MANY uses for zig. If I may be permitted some shameless self-promotion, zig is pretty awesome: https://www.youtube.com/watch?v=l848TOmI6LI https://www.youtube.com/watch?v=l848TOmI6LI
- hansvm 6y agoC doesn't have to die. The point was just that many places where C is currently a good choice you'll find that Zig is also a good choice, and if you like the "but better" features it brings to the table then you'll be inclined to choose Zig. As another comment pointed out, you'll have minimal regret when doing so because the C interop is excellent.
- txdv 6y agoAnother? Can you give me examples of other better Cs?
- floatboth 6y agoD, in the aptly named betterC mode
- deleted 6y ago[deleted]
- MaxBarraclough 6y agoAda is often overlooked. Very short summary: It's like C in that it's plain imperative code that compiles down to efficient machine-code pretty naturally. It's unlike C in that it's much safer, with excellent support for strong optional runtime checks. Ada has excellent interoperability with C. Syntactically it's pretty different from C.
- audunw 6y ago> It's another "C but better" language. This is actually a surprisingly underserved field. There's relly very few language that actually tries to be just C but better. Go: Uses garbage collection, not very applicable Rust: Too complex, more like C++ but better. Bit too cumbersome to write "unsafe" code D: More like Java/C++, although they have a "better C" mode, but feels like an afterthought Nim: Uses garbage collection.. like D they're kind of trying to reach down into the plain C usecase, now with some nice reference counting stuff. Also relatively complex Some actual attemps that I know of: C2, Odin Some reasons why Zig is a better attempt at "C but better": - Complexity of the language is just a little higher than C, and mostly in ways that resolves issues with C that leads to its own complexities (Like, the C pre-processor is simple, but solving problems with it can be surpringly complex. Or how you may have to resort to compiler extensions/pragmas to solve real problems) - The Zig compiler is also a fantastic C compiler - C headers can be imported and used directly in many cases - Significant parts of the language is dedicated to excellent interop with C (even has syntax for 0-terminated strings) - Cross-compilation is a highly prioritized use-case (C is very popular in embedded programming, where cross-compilation is essential)
- MaxBarraclough 6y agoDon't forget Ada!
- hansvm 6y agoI don't think it's fair to dismiss some of those, like Rust. That project very explicitly wants to be viable as a safe tool for writing systems code, and the fact that it's accumulated a lot of complexity doesn't take away that intent (or the fact that it's being successfully used in that capacity). That said, I am super excited about the Zig project, and it hits a sweet spot for me in a way that none of the other "C but better" projects have. Calling it another "C but better" language wasn't an attempt to disparage the project, but to classify it.
- yellowapple 6y ago> That project very explicitly wants to be viable as a safe tool for writing systems code Right, but that's a (slightly) different goal from being a C replacement. There are other systems languages besides C, and C is used beyond systems programming.