3 ms·
Java is also considering making value objects that don't have that overhead: https://openjdk.org/jeps/8277163 https://openjdk.org/jeps/8277163 .NET has someth
by PaulHoule 4y ago
Java is also considering making value objects that don't have that overhead:
https://openjdk.org/jeps/8277163 https://openjdk.org/jeps/8277163
.NET has something like that already, but it would make a huge difference for things like Optional or if you want to make a type for, say, complex numbers where there is just 64-bits of data (for FP32) and even a 64-bit object header would be 100% overhead. Value objects could be possibly allocated on the stack and completely bypass the garbage collector in some cases.
Note that with that overhead, Java is an environment in which you can write multithreaded applications with good reliability and scaling, something that WebAssembly definitely isn't.
- bcrosby95 4y agoI've been lightly following some of their work here. From the outside, it seems like a lot of this has been born from optimizing the JVM over the past few decades, running into fundamental problems with how dynamic the JVM can be, then targeting changes for making that dynamicism opt-in, either through JVM flags or new features. I do think some of it is kinda interesting: some people might say "if you never do X, we can guarantee Y". But it's nice, as a programmer, to be told "if you use feature A, you will never do X, which means we can guarantee Y". It's a lot more comforting that I can't slip up and accidentally do X.
- titzer 4y ago> It's a lot more comforting that I can't slip up and accidentally do X. Indeed, this is why value semantics (i.e. structural equality) for language constructs like ADTs is so wonderful. Because a program can never observe "identity", which is an implementation detail, the implementation doesn't have to use objects at all underneath. That opens a whole host of value representation options that aren't otherwise available.