Something I wonder about is #4, especially word tearing and booleans wrt. records. Records are immutable. So in principle it should be possible to represent booleans inside records as exactly one bit, since concurrent writes simply aren't a problem, right?
Yes, in principle. Practice would probably reveal lots of weird corner cases. For example, Java can still write to the otherwise final field with Reflection, which leaves the fields that are conceptually immutable still being mutable. Plus, as mentioned in the sidebar, it still leaves the problem how to address those individual fields on VM side. These things are not insurmountable, but they can tilt the cost/benefit unfavorably.
4
u/Polygnom Apr 14 '20
Quite interesting and helpful.
Something I wonder about is #4, especially word tearing and booleans wrt. records. Records are immutable. So in principle it should be possible to represent booleans inside records as exactly one bit, since concurrent writes simply aren't a problem, right?