Hacker Timesnew | past | comments | ask | show | jobs | submitlogin

I don’t see how it’s an improvement over C# structs. C# structs are value types so they are copied when assigned to a variable like primitives. There is no ambiguity because it’s a struct.

To avoid copying you have to explicitly declare a ref variable/parameter.

You can get the same immutability as value classes by using ‘readonly struct’s or ‘readonly record struct’s.

Java value classes are stranger because they are heap allocated by default and are only flattened/scalarized/stack-allocated when certain conditions are met. It’s the same as a class, but with extra restrictions, so that the JVM can possibly optimize memory layout at runtime.



Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: