3 ms·
I tried using Zig for a little bit, and it just doesn't feel ergonomic to use _for me_. It's not 1.0 so I'm hoping that a lot of that will be ironed out, but so
by Decabytes 4y ago
I tried using Zig for a little bit, and it just doesn't feel ergonomic to use _for me_. It's not 1.0 so I'm hoping that a lot of that will be ironed out, but some of it is baked into the language. Being forced to assign variables to _ if you aren't using them somewhere else in the program annoyed me a lot more than I expected. Especially in the learning phase when you are asking a lot of questions and have to write up toy examples of what you are trying to do when asking people for help.
I also ran into an issue where I wanted to initialize an array with 30k 0 values and I ended up having to write a loop to do it, and ran into issues with the loop and assigning values. It felt like if the language was going to be militant about certain things to prevent you from making mistakes, that it should just go the whole way. At least with Rust after fighting with the borrow checker I would know I had a safe program. With Zig I have to fight with the langauge, but then it's not even memory safe once I get everything working
- kristoff_it 4y agovar arr: [30_000]u8 = undefined; for (&arr) |*x| x.* = 0;
- hbossy 4y agoThat sounds like a loop.
- anonymoushn 4y agoyou could initialize it to {0} ** 30000 instead
- AnIdiotOnTheNet 4y agovar arr = std.mem.zeroes([30_000]u8); P.S: Not a loop. The implementation of std.mem.zeroes for an non-sentineled array is: return [_]info.child{zeroes(info.child)} ** info.len; Which in this case will be equivalent to: return [_]u8{0} ** 30_000; Which uses the comptime-only `*` operator to expand the single-item u8 array with value 0 into an array of 30k 0s.