logoalt Hacker News

foobiekrlast Wednesday at 7:53 PM2 repliesview on HN

Two big issues in Golang are that you can't actually build an arena allocator that can be used for multiple types in a natural way.

The other is that almost no library is written in such a way that buffer re-use is possible (looking at you, typical kafka clients that throw off a buffer of garbage per message and protobuf). The latter could be fixed if people paid more attention to returning buffers to the caller.


Replies

bilbo-b-bagginslast Thursday at 1:11 AM

You totally can build it using unsafe and generics. I’ve done it with mmap-backed byte slices for arbitrary object storage.

fpolinglast Wednesday at 11:00 PM

Rust also suffers from libraries returning a newly allocated strings and vectors when the code should allow to pass a pre-existing string or vector to place the results.

Granted the latter leads to more verbose code and chaining of several calls is no longer possible.

But I am puzzled that even performance-oriented libraries both in Go and Rust still prefer to allocate the results themselves.