News for hackers. Stuff that matters.
Re:Data Processing Benchmark Featuring Rust, Go, Swift, Zig,... by xigoi on Sunday February 01, 2026 @06:03AM (#46845276)
The true penalty of Java is that product types have to be heap-allocated, as there is no mechanism for stack-allocated product types.
Re:Data Processing Benchmark Featuring Rust, Go, Swift, Zig,... by pron on Sunday February 01, 2026 @07:14AM (#46845668)
You're right that Java lacks inline types (although it's getting them really soon, now), but the main cost of that isn't because of stack allocation (because heap allocations in Java don't cost much more than stack allocations), but because cache misses due to objects not being inlined in arrays.
Re:Data Processing Benchmark Featuring Rust, Go, Swift, Zig,... by pron on Sunday February 01, 2026 @07:40PM (#46851003)
P.S.

Even for flattened types, the "abstraction penalty", or, more precisely, its converse, the "concreteness penalty", in Java will be low, as you don't directly pick when an object is flattened. Instead, you declare whether a class cares about identity or not, and if not, the compiler will transparently choose whether and when to flatten the object, depending on how it's used.

Re:Data Processing Benchmark Featuring Rust, Go, Swift, Zig,... by Someone on Sunday February 01, 2026 @11:36AM (#46847338)
> product types have to be heap-allocated

Conceptually, that’s true, but a compiler is free to do things differently. For example, if escape analysis shows that an object allocated in a block never escapes the block, the optimizer can replace the object by local variables, one for each field in the object.

And that’s not theoretical. https://www.bettercodebytes.com/allocation-elimination-when-..., https://medium.com/@souvanik.saha/are-java-objects-always-cr... show that it (sometimes) does.