Remix.run Logo
joe_mwangi 7 hours ago

Yup. Totally agree. Java does needs an array of structs. Hopefully value classes will help out through flattened array. But in future, one can use value records with this library with probable zero cost allocation. But the library doesn't use any reflection calls for get and set hence high performance as a result, and using records helps a lot with escape analysis. Planning to do some serious benchmarks soon. Some preliminary tests shows it's similar to c code (example code in test package). Performance suffers if record fields are arrays due to heap allocation of arrays.

PaulHoule 6 hours ago | parent | next [-]

The thing I coded where I felt the weight of the GC the most was a chess engine in Java that needed transposition tables. Like using regular HashMap(s) or anything similar it was too slow to really speed up the engine. If my son had stayed interested in chess I would have coded up an off-heap transposition tables but he switched to guitar which changed my side projects.

joe_mwangi 6 hours ago | parent | next [-]

Hope you come back. Would be cool to venture in this new data oriented programming phase java has invested a lot in.

traderj0e 5 hours ago | parent [-]

I'm glad they saw the light. Last time I used Java was in high school when it was version 7, when it was pure OOP. Didn't even have lambdas. After I learned other languages, I didn't want to use Java again, seemed like a lot of boilerplate for something that didn't even give good performance.

PaulHoule 3 hours ago | parent | next [-]

I use Java all the time for ordinary programming at work, I think it is great, but I'm not in a hurry to mess with stuff off-heap.

dionian an hour ago | parent | prev [-]

Java has always given good performance for most of my use cases. Like backend servers where startup time is mostly irrelevant.

cindyllm 5 hours ago | parent | prev [-]

[dead]

fweimer 6 hours ago | parent | prev [-]

I doubt value classes will be helpful here because the array would have to be immutable. Context: https://openjdk.org/jeps/401

spockz 5 hours ago | parent | next [-]

Why does the array need to be immutable? Isn’t it enough to allocate the pessimistic max size of the record times the size of the array? In go slices work quite nicely to deal with “immutable” arrays and still be able to work on views on those arrays while keeping the same memory backing.

kbolino 3 hours ago | parent | next [-]

There's two problems as I see it.

The first is that value types themselves are immutable. This affects code generation and optimization. If you were to modify the value with unmanaged code then you may not observe the modification properly from managed code. Maybe this restriction will get relaxed, but I don't see that on any roadmap any time soon.

The second problem is that value types are still nullable. The flattened array is not going to be identical to a Go slice or a C# Span etc. because it has to track the nullness of each element. It seems they don't want to nail down the exact storage format for that yet, possibly to change it in the future, and possibly because they want to add language-level control over nullability eventually too.

3 hours ago | parent | prev [-]
[deleted]
joe_mwangi 6 hours ago | parent | prev [-]

Yeaaah. You might be right. Hopefully we have this one day https://openjdk.org/jeps/8261007