4 ms·
The point of C and Zig is that you can solve any kind of problems with them. In particular there is much more to memory reclamation than garbage collectors or R
by Comevius 5y ago
The point of C and Zig is that you can solve any kind of problems with them. In particular there is much more to memory reclamation than garbage collectors or Rust's borrow checker. Some of the reclamation schemes offer wait-freedom, or efficiently support linearizable operations.
- pjmlp 5y agoAny kind of problem? So how do you solve SIMD with C, without language extensions? C is not a special snowflake.
- turminal 5y agoAre there languages that "solve" SIMD?
- Comevius 5y agoSIMD is not a problem, it's hardware. Compilers tend to take advantage of the CPU-specific SIMD registers and instructions, or you can use them explicitly. Writing generic SIMD code is more portable. C has libraries, and Zig also has vector primitives available through built-in functions.
- pjmlp 5y agoAny language can have libraries, C is not special here, nor is Zig. In fact, a few GC enabled languages have explicit SIMD support.
- maleldil 5y agoWhat can C and Zig do that Rust can't?
- Comevius 5y agoNothing if unsafe Rust is considered, though Zig does not require you to fight the language nearly as much. This is especially obvious with embedded. Zig's philosophy of no hidden control flow or allocation makes things simple. Simplicity is power. For certain problems you would want a TLA+ specification for safety and especially liveness either way. It's not like Rust absolutely guarantees correctness in all cases. Rust sits in a sweet spot between C/Zig and languages like Java, but it's not an appropriate replacement for either of them.
- 3a2d29 5y agoCertainly Rust sits where C++ is. Zig and Rust are definitely best used for different things, but I think sweating rust off as in between C and Java is inaccurate.
- politician 5y agoThis is kind of a trick question because they are all Turing Complete, but so is Assembly. The best way to interpret your question, then, is not “what is possible” but rather “what is simple to express correctly” and “what is simple to get correct eventually”. Those are questions about how tricky it is to get something to compile in the language and which tools exist to help determine whether a compiled program does what’s expected and does not do what’s not expected.
- maleldil 5y agoIt wasn't a trick question. I'm not asking it in the same tone as someone would ask 'What can C do that Java can't?'. I believe that Rust can be as low level as you want. If you have to fight the language to accomplish something, it's because you're probably trying to do something unsafe, and Rust will let you do that if you pay the price. I was looking for examples of real cases where Zig is a better option than Rust. And while Zig is a lovely language, its main points against Rust are that it lets you do unsafe things more easily, and it's easier to learn.