News for hackers. Stuff that matters.
Re:Swift at Apple: Migrating the Password Monitoring Service... by dwaite on Wednesday June 04, 2025 @01:39AM (#44177547)
Basically no.

Even records are not value-based types, but rather are classes limited to value-like semantics - e.g. they can't extend types, are expected to have immutable behavior by default where modification creates a new record instance, and the like.

The JVM theoretically can perform escape analysis to see that a record behaves a certain way and can be stack allocated, or embedded within the storage of an aggregating object rather than having a separate heap allocation.

A C# struct gets boxed to adapt it to certain things like an Object state parameter on a call. The JVM theoretically would just notice this possibility and decide to make the record heap-allocated from the start.

I say theoretically because I have not tracked if this feature is implemented yet, or what the limitations are if it has been.

There are no comments on this comment yet.