I think the biggest GC-related performance benefit of value types isn’t that you can allocate them on the stack, since a generational GC will easily eat up those allocations. It’s so that more *long-lived* data can become pointer-free and not scanned at all.
-
-
Has any runtime made per-type decisions on representing particular types as values versus boxes to maximize ? In C# the rule is that structs are always values, objects are always boxes.
-
I don’t know of one. I’ve thought about such optimizations, but it seems hard, because the semantics of value vs. reference types are so different. Plus it would have to be a global optimization, which has problems with separate compilation, etc.
- 1 more reply
New conversation -
-
-
Agreed. But who needs GC when we have Rust.
-
Rust is pretty amazing! But, it's called "fighting the borrow checker" for a reason, it's very hard to safely express some things in it, and things like Rc<> can have performance characteristics worse than GC in many respects - 3 more replies
New conversation -
-
-
Java has value types since JRE 8, I think
-
looks like it's JRE 10, not 8 as I thought
- 2 more replies
New conversation -
-
-
For me value types would be more about language features that would allow to affect cache locality, memory consumption, to specify true generic classes with method specialization, methods with multiple return values, direct access to off heap objects in memory mapped files.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Simulating a million particles in Java I’d suspect would be worth moving them to a memory mapped file and out of the GC’d heap altogether.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.