3 ms·
> Rust can also do arena allocations, Is there a language that can't? The author isn't saying it's literally impossible to batch allocate, just that the defau
by Mawr 11mo ago
> Rust can also do arena allocations,
Is there a language that can't?
The author isn't saying it's literally impossible to batch allocate, just that the default happy path of programming in Rust & Go tends to produce a lot of allocations. It's a take more nuanced than the binary possible vs impossible.
- seanmcdirmid 11mo agoPretty hard to do arena allocation in Java without JVM primitive support.
- jeberle 11mo agoNot sure what you mean by "primitive support". Java 22 added FFM (Foreign Function & Memory). It works w/ both on-heap & off-heap memory. It has an Arena interface. https://openjdk.org/jeps/454 https://openjdk.org/jeps/454 https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/foreign/Arena.html https://docs.oracle.com/en/java/javase/25/docs/api/java.base...
- Dylan16807 11mo agoSo, one year ago? After more than 25 years without it? And a lot of people writing Java can't update to that.
- jeberle 11mo agoYeah, FFM adds many quality-of-life features - scoped lifetimes being a standout. If you just want an arena interface, ByteBuffer has been there since Java 1.4 (2002). It also does off-heap w/ ByteBuffer.allocateDirect(). https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/nio/ByteBuffer.html https://docs.oracle.com/en/java/javase/25/docs/api/java.base...
- seanmcdirmid 11mo agoThat brings back some memories...when Frank Yellin and Sheng Liang (from Javasoft) visited our team at UW I think in 1996 or 1997, we mentioned that our bytecode verifier/failure injector was really fast because we were using arena allocation, which was only possible (at the time) because we did the project in C. If you are using non-pointer offsets, you totally can do arena allocation with a byte buffer. I still don't get how you can do it safely with high level objects even with the mechanism described above, but there are definitely lots of unsafe ways to do it.