logoalt Hacker News

It's all about the allocator

44 points • by ibobev • last Sunday at 3:34 AM • 13 comments • view on HN

Comments

KolmogorovComp • today at 8:46 PM

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.

krukah • today at 7:29 PM

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.

daxfohl • today at 6:55 PM

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?

yeureka • today at 4:48 PM

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

➕ show 1 reply
fwlr • today at 4:29 PM

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!

➕ show 1 reply
ngriffiths • today at 5:54 PM

> 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"

alfiedotwtf • today at 3:17 PM

“It’s all about the Pentiums, baby”

ElUncivio • today at 7:32 PM

[dead]