| ▲ | rahen 3 hours ago | ||||||||||||||||||||||||||||||||||||||||
Use Rust if you're not writing code yourself. The borrow checker will catch all kinds of bugs that AI-generated code will happily compile in Zig but will blow up as UB at runtime. Zig's value prop is different and closer to a modern C: it fits in your head and maps fairly closely to assembly. There is no hidden control flow or hidden allocations, so you can tweak performance at a very low level. You're the pilot, not the compiler. Rust trades the low-level clarity for compiler-enforced safety. If you're not a code artisan or don't care about being one, then please use Rust. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | solatic 2 hours ago | parent | next [-] | ||||||||||||||||||||||||||||||||||||||||
> The borrow checker will catch all kinds of bugs that AI-generated code will happily compile in Zig but will blow up as UB at runtime. This has not been my experience; Claude does a great job of writing unit tests for the Zig code, and combined with Zig's fuzzing features and a Python-based integration testing suite, I have avoided hitting runtime UB so far. In exchange, I get much faster compile times, which are important for the agentic development loop. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | je42 an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
So far claude has been fine to generated zig code. Dont have lots of issues. Tijy local models have more problems with zig, need additional instructions. In general, what helps is to instruct ai to use test coverage to ensure the cover all edge cases with tests. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | bsaul an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
it's also my opinion. Which makes me wonder : isn't there an opportunity to create a variant of rust that would make absolutely zero compromise on UB and safety at the detriment of user experience ( which we don't care about now, with AI generating the code) ? Like programming in a kind of super strict IL. Or the opposite : super poweful, super abstract language, yet extremely strict. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | Ygg2 an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
Use Rust if you want to write in a memory safe, high performance language. > Zig's value prop is different and closer to a modern C: it fits in your head and it maps fairly closely to assembly. This can't be correct for the simple reason that it has both a modern optimizing compiler (LLVM) and UB. A modern compiler will try to autovectorize your code, so you don't really know what the assembly will be. UB gives compiler license to rewrite your code however it sees fit. | |||||||||||||||||||||||||||||||||||||||||
| ▲ | zuzululu an hour ago | parent | prev | next [-] | ||||||||||||||||||||||||||||||||||||||||
Can LLMs not write Zig code ? I'm not really understanding your explanation for why we can write other languages with LLM but not Zig here. > Rust trades the low-level clarity for compiler-enforced safety. If you're not a code artisan or don't care about being one, then please use Rust. Not really seeing the connection here. What do you mean by code artisan? Are you trying to gatekeep Zig because you think Zig is too difficult for LLMs? | |||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||||
| ▲ | eptcyka 2 hours ago | parent | prev [-] | ||||||||||||||||||||||||||||||||||||||||
> You're the pilot, not the compiler. This to me reads like an LLMism. | |||||||||||||||||||||||||||||||||||||||||