|
|
|
|
|
by IshKebab
407 days ago
|
|
I tried Zig a bit and found it quite nice, but it is very low level. Like in Rust you concatenate strings like this: let result = format!("{a}{b}{c}");
In Zig it's something like this: const allocator = std.heap.page_allocator;
const parts = [_][]const u8{"a", "b"};
const result = std.mem.concat(allocator, &parts[0], 2) catch @panic("allocation failure");
defer allocator.free(result);
I dunno if I want to write any really significant programs like that. At least not any that use strings a lot! |
|
For wanting to avoid fiddling with multiple repeated alloc/defer-free, it's often convenient to use the arena allocators that allow you to release everything with a single `defer arena.deinit()`