Hacker news

  • Top
  • New
  • Past
  • Ask
  • Show
  • Jobs

It's all about the allocator (https://aarol.dev)

60 points by ibobev 5 days ago | 16 comments | View on ycombinator

Panzerschrek about 5 hours ago |

I don't think it's that necessary to return back to manual memory management (Zig-style) and abandoning proper RAII (Rust-style) to spare some memory. With a little bit effort it's possible to achieve good memory efficiency without sacrificing safety (by manually managing allocators).

Chromium-based applications consume so much memory, not because they don't use manual memory management, but because JS used for application code isn't nearly as efficient in memory usage as any other proper language. Also the browser engine itself is optimized in such a way, that it sacrifices memory usage to gain more speed.

yeureka about 17 hours ago |

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

KolmogorovComp about 13 hours ago |

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 about 14 hours ago |

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.

fwlr about 17 hours ago |

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!

ngriffiths about 16 hours ago |

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

daxfohl about 14 hours ago |

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?

alfiedotwtf about 18 hours ago |

“It’s all about the Pentiums, baby”

ElUncivio about 14 hours ago |

[dead]