5 ms·
Unfortunately, Rust is not a good choice for this kind of tricks. This is where Zig shines. In Rust, you can’t even use proper arenas, which can help a ton with
by f311a 20d ago
Unfortunately, Rust is not a good choice for this kind of tricks. This is where Zig shines. In Rust, you can’t even use proper arenas, which can help a ton with allocations.
Cloudflare started to pick Zig recently, for projects, that have memory constraints.
- afdbcreid 20d ago> In Rust, you can’t even use proper arenas You definitely can and this is done a lot. What you might mean is that you can't use standard library's collections with them (this is getting stabilized soon!) and have to use third-party, but that is a different thing than "can't use arenas". > Rust is not a good choice for this kind of tricks. Rust can do those tricks, but it's true that it is hard than in C or Zig. That said there are often crates to help.
- f311a 20d agoStabilized soon, really? They did not stabilize it after 10 years and were thinking about different approach. I thought it’s dead.
- kibwen 20d agoYes, really. The design has been decided upon ( https://hackmd.io/nNHdKkp1TTK7jat0I-ABqA https://hackmd.io/nNHdKkp1TTK7jat0I-ABqA ) and the implementation has been updated to match ( https://github.com/rust-lang/rust/pull/157428 https://github.com/rust-lang/rust/pull/157428 ). The stabilization PR is just waiting on final approval by the relevant team members, with no remaining concerns currently listed: https://github.com/rust-lang/rust/pull/156882#issuecomment-5350668934 https://github.com/rust-lang/rust/pull/156882#issuecomment-5...
- chlorion 20d agoI'd like to know why I can't use arenas in rust? Especially considering that I have used them before in rust.
- f311a 20d agoYou can’t allocate collections without nightly or without reimplementing them in the library. Every implementation uses it’s own set of trade offs to provide safety in unsafe implementation.
- kibwen 20d agoRust supports arenas just fine ( https://crates.io/crates/bumpalo https://crates.io/crates/bumpalo ), and if you mean the support for using custom allocators in the standard library collections, that's as stable as Zig is.
- f311a 20d agoThere are more than 10 crates for arenas with different tradeoffs, I'm well aware of them. They are still very limited compared to C/Zig.