logoalt Hacker News

speedgoose • yesterday at 10:05 AM • 6 replies • view on HN

> It's going to take a bit of time for the ecosystem to catch up to custom allocators.

I havn't published any popular rust crate. I think my crates are downloaded by me and robots only, so I don't have a lot of authority. I have no wishes to think about custom memory allocators. I don't want them. I consider those as unnecessary complexity for a niche use case, and I'm a bit annoyed that they will pollute the Rust landscape. I understand why people need them though, but I fear that Rust is going to be the next C++: a bloated programming language with features to please everyone and a lack of simplicity. It's already complex enough.


Replies

koverstreet • yesterday at 10:35 AM

This isn't something baked into the core language like C++ features tend to be. This is standardization of library code, thoroughly vetting what people already had to do but in incompatible ways.

This is the kind of work that is making Rust far easier and more productive for systems work, including even kernel development, than the bad old days of when every project was a monolith and everyone was reinventing the wheel.

Over the past several months I've been converting bcachefs to Rust, and as part of that I have a whole truckload of code that I can now release as small self contained crates that anyone can use: safe RCU, an async runtime suitable for kernel IO paths, a fully lockless implementation of Cuckoo - custom allocators getting standardized is directly pertinent because now all that code (RCU, especially) will compose much better with other people's crates.

➕ show 1 reply
spacechild1 • yesterday at 12:48 PM

> I consider those as unnecessary complexity for a niche use case

Custom allocators are certainly no niche use case, they are very common low level programming, from microcontrollers to audio software to video games.

pjmlp • yesterday at 10:39 AM

As proven multiple times since JOVIAL, complex features are there for a reason.

➕ show 1 reply
ozgrakkurt • yesterday at 10:31 AM

It already is bloated.

I'm not saying it is a bad language as I use it since 9 years and still write new code in it.

But if you compare writing an bump allocator in c or zig vs rust, it is comically bloated. Same applies to anything like a vector or a hashmap or anything else low level.

You get a binary that is multiple megabytes if you just write a webserver on the path of least resistence.

➕ show 2 replies
lenkite • yesterday at 11:12 AM

Rust's async is 1000x more complicated than mere custom allocators, so the complexity argument is invalid. You are complaining about a mote of sand when there is a gigantic mammoth stomping on your head.

➕ show 1 reply
Joker_vD • yesterday at 12:41 PM

> I have no wishes to think about custom memory allocators. I don't want them. I consider those as unnecessary complexity for a niche use case,

Well, not to be rude, but Python and Go exist, you know. But if you're picking Rust (or Zig) — you will have to think about lifetimes, ownership, and allocations, that's the language's raison d'être.

> with features to please everyone and a lack of simplicity.

Like async! Compared to that barrel of worms, the new allocators are a complete non-issue. A two-functions trait, that Vec's and Box's "new_in" method use under the hood, with straightforward semantics — that's as complicated as having xmalloc()/xfree() in your C project.

➕ show 1 reply