It's where Zig outshines Rust the most, IMO.
TBF Rust v1.100 makes a big leap in permitting custom allocators, but mandating would be ideal in the spirit of "explicit is better implicit". I like adding lints to defend against some of these footguns, but more compiler-driven transparency around quiet allocations would be so nice.
I knew it's not the point of the article, but would AI be any better at translating code to zig? Or would it make the same slow design, just with all the allocations being explicit?
Bloomberg writes all of its C++ using an allocator aware version of the STL because of this issue. It’s open source and very high quality: https://github.com/bloomberg/bde
Oh, wow, this is a fantastic explanation for why “Zig makes you pass the allocator around as an argument to all your functions” is A Good Thing, Actually. Kudos to the author!
> So, if you want to write truly memory-efficient code, just asking AI to do it for you might not be enough.
In hindsight, it would be pretty funny if "hey can you rewrite this game in Rust" is sufficient instructions to end up with memory-efficient code. In fact it would be pretty funny if it were enough to get this thing written in Rust, for all the specific details of what you actually mean when you say "this game"
“It’s all about the Pentiums, baby”
[dead]
This is not an issue with Rust the language but with the standard library which assumes allocation is not a big deal.
Traditional where allocations matters, like for embedded devices you would use no-std.
An alternative standard library with a different focus is entirely possible.
Or as a middle ground a lint flagging allocations.
As an aside I believe the last ‘expect’ issue to triggers an existing clippy lint.