Unfortunately we went crazy with heap only types, on the other hand thankfully the pendulum is turning around and most compiled languages are having them back.
However nothing of this matters if you end up shipping the app inside Electron.
This isn't fully correct. In Zig, the common pattern is that any function which allocates accepts an explicit allocator parameter; if you don't pass one explicitly, you don't get any heap allocations.
Rust doesn't make things quite that visible. But, if you restrict yourself to the standard library and crates designed with this in mind, allocations are usually not too hard to find. And you can always use `#![no_std]` without `alloc` if you want to be sure. Neither language is ever going to insert a heap allocation if it's not somewhere in the source.
const std = @import("std");
fn makeBuffer(n: usize) ![]u8 {
return std.heap.page_allocator.alloc(u8, n);
}
Here are a few examples from the last release of Bun before the rewrite into Rust.https://github.com/oven-sh/bun/blob/bun-v1.3.14/src/install/...
https://github.com/oven-sh/bun/blob/bun-v1.3.14/src/shell_pa...
The allocator via function parameter is only a convention and only even one convention. It is certainly a strong convention (throughout the standard library anyway) but it is just a convention.
Recent Rust also has the ability to pass allocators but that's the same thing. And even if you use no_std in Rust you might call into some other library's no_std function that allocates and you wouldn't be able to grep for that.