12 ms·
I've been using Zig for few days. And my gotchas so far: - Can't `for (-1..1) {`. Must use `while` instead. - if you allocated something inside of a block and
by scotty79 11mo ago
I've been using Zig for few days. And my gotchas so far:
- Can't `for (-1..1) {`. Must use `while` instead.
- if you allocated something inside of a block and you want it to keep existing outside of a block `defer` won't help you to deallocate it. I didn't find a way to defer something till the end of the function.
- adding variable containing -1 to usize variable is cumbersome. You are better of running everything with isize and converting to usize as last operation wherever you need it.
- language evolved a bunch and LLMs are of very little help.
- scotty79 11mo agoI don't know if that's just aged noob in me speaking but so far, while Rust has "zero cost abstractions", Zig feels like it has "Zero abstractions". Deallocating the wrong thing or the right thing too soon bit me in th ass so much already that I feel craving for destructors.
- riku_iki 11mo agoRust is not zero cost abstractions, they make decision on case-by-case basis.
- scotty79 11mo agoIt's their tagline and it's how it feels. I cen freely abstract. Zig is kind of making me index into byte array all the time.
- riku_iki 11mo agoRust may feel like this in general, but I seen multiple discussions when people spot cases where rust is much slower than C++, they start looking at them, and the finding is that Rust is not zero-cost abstraction, and induce penalty sometime, while C++ is always zero cost abstraction.