6 ms·
Why Zig?
by Rygu 5y ago
Why Zig?
- indymike 5y agoWhy not Zig? Its a pretty fun language...
- AnIdiotOnTheNet 5y agoWell there are still quite a lot of compiler bugs. I personally have open issues going back as far as 2018. Knowing the compiler has bugs and that new ones are constantly being discovered makes debugging a pain because you have a lot less confidence that the problem is your code. I have many times blamed the compiler for my mistakes, something I've almost never done with C.
- indymike 5y ago> I have many times blamed the compiler for my mistakes, something I've almost never done with C. Early on, I remember dealing with lots of bugs in C compilers in the mid and late 80s. It takes time.
- pjmlp 5y agoPersonally I dislike the @ love, feels a bit like being in Objective-C land, imports feel like JavaScript AMD modules, and still use-after-free issues. Otherwise it is pretty much Modula-2, with C flavoured syntax and compile time execution. Overall, the use-after-free is what irks me.
- dnautics 5y agoNot OP, but here is what I can think of: - Low level - great C interop - Good toolchain ergonomics, except for no pkg manager yet - Great cross-compilation - Fast compilation (incremental coming soon) - Ideal for things where ownership rules can get complicated (ECS e.g.)
- genocidicbunny 5y agoThe C interop is especially useful for gamedev since so many libraries have a C interface and thus can be relatively easily used in Zig.
- collegeburner 5y agoIntersting, some follow up questions: - Fast compilation: isn't it llvm? So how faster compared to C++/Rust/others that use it? - Ownership rules/ECS: what about zig makes this especially good? The only language that comes to mind in this respect is Rust and its borrow checker, is it similar in Zig?
- runevault 5y agoPart of Rust's problem last I knew was it throws a lot more than it necessarily has to at the LLVM backend. So a front end that takes the time to lessen the burden could run faster despite using the same tooling.
- actuallyalys 5y agoPart of it (perhaps the majority) is excessive intermediate code. But at least some of it is that Rust's abstractions are more complex/involved. The "zero cost" doesn't refer to compilation time.
- runevault 5y agoIs that part paid in the Rust or LLVM portion of the compiler chain?
- dnautics 5y agorust portion. For example, LLVM has no internal concept of ownership.
- actuallyalys 5y agoThat's true of borrowing, but I'm not sure if it's true for other abstractions. I imagine generics (due to monomorphization) adds to the burden on the LLVM side.
- dnautics 5y ago
- klyrs 5y agoBecause zig needs better game development tooling!
- zarzavat 5y agoZig is like C but better. It fixes all the pain points of C without adding any extra complications (Rust - borrow checker, Go - GC, C++ - everything).
- pcwalton 5y agoMemory safety is a pain point of C, and Zig doesn't fix that. There is no free lunch: you either accept garbage collection or deal with something that resembles the borrow checker.
- pjmlp 5y agoFrom my point of view in terms of memory safety with Zig, we could just use Modula-2 or FreePascal/Delphi instead, but they aren't as fashionable.
- speed_spread 5y agoAs much as I love Delphi, the language syntax hasn't aged well. Single pass compilation was great to have in the 1980's but nowadays even the humblest Raspberry Pi will chew through thousand of lines of C++ and link an optimized executable within seconds. We deserve and can afford a lot more comfort than Pascal (and siblings) provides. Incidentally, modern language ergonomics also adds much in the way of coding safety, making usage of explicit allocation control a more manageable problem than it was 30 years ago.
- pjmlp 5y agoIndeed, and that is why for me modern language ergonomics is a synonym for Swift, C#, Nim, D, and Rust. For Zig to be part of that list, a story for use-after-free must exist as well. Others won't agree with me, and that is fine, different strokes for different folks.
- kristoff_it 5y agoYou could build the same argument for all other types of correctness: either your program is formally validated to be correct, or it's broken. While there is some truth to that, if that's the only analysis you're willing to do, then you're going to fail spectacularly hard at recognizing the advantages of TypeScript over JS, for example. Zig and C share a similar relationship across many axes, including memory safety.