Hacker News new | ask | show | jobs
by dnautics 1703 days ago
Not 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.)

2 comments

The C interop is especially useful for gamedev since so many libraries have a C interface and thus can be relatively easily used in Zig.
Intersting, 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?

1. Both zig and rust compile to intermediate representations which are then compiled to llvm IR. Most of the compilation woes of rust are in the early stage IR.

2. Zig doesn't have ownership rules, which can get in the way of important data structures for gaming.

Part 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.
Part 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.
Is that part paid in the Rust or LLVM portion of the compiler chain?
rust portion. For example, LLVM has no internal concept of ownership.
That'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.