Re:Java 14 Feature Spotlight: Records
by dajohnson89 on Tuesday February 04, 2020 @11:58PM
(#22244155)
I always thought array elements were contiguous in memory? Is it that the objects are contiguous, but the pointers are not? If so, this does seem pretty expensive and I wonder if there's any workarounds.
Re:Java 14 Feature Spotlight: Records
by touisteur on Wednesday February 05, 2020 @03:21AM
(#22244947)
Well arrays if elementary types are contiguous, yes. Arrays of objects are arrays of references to instances. The references are contiguous, but they point to instances all over the place.
Re:Java 14 Feature Spotlight: Records
by dajohnson89 on Thursday February 06, 2020 @01:30PM
(#22258731)
that makes perfect sense, thank you
Does it strike anyone as odd that something trivial in toy languages from the 70s is a separate project 30 years in and named for the the heaven of the gods in the world of Java?
On the other hand the toy languages from the 70s never caught on. In many workplaces Java is considered the high performance language and most devs would prefer Python/PhP at 1/100th the performance.
I don't know what point you are making, but C had structs in the 70s too and it hasn't been a technical hurdle to implement there either. It's literally a few instructions of asm.
Thanks, you're right on. That's what I'm after and that's exactly what Java needs to be useful for doing high performance computations in a sane fashion.
Re:Java 14 Feature Spotlight: Records
by seanmceligot on Tuesday February 04, 2020 @03:44PM
(#22240740)
I switched to java from c in the mid 90's. I remember thinking how ridiculously wasteful it was to allocate an array on classes one at at time rather than as a block of memory. I think I was using berkeley DB at the time in c and it let you do that.
You have direct buffers but that's that...
You can use multiple arrays of primitives, inverting the problem 90%. None of the solutions is optimal, easy to maintain, etc.
Yes there is also the sun.misc.Unsafe class but of course that's skating on thin ice.
That ship has sailed.
What do you mean?
I think there was an opening for a fast safe alternative to C++ in HPC, but I think Rust has taken that spot now. Control over allocation, alignment and placement is important in HPC and imo Java took too long to address these issues.
[0] https://openjdk.java.net/jeps/169
[1] https://dzone.com/articles/valhalla-lw2-progress-inline-type...
[2] https://wiki.openjdk.java.net/display/valhalla/Main