News for hackers. Stuff that matters.
Re:Java 14 Feature Spotlight: Records by chris_overseas on Tuesday February 04, 2020 @12:23PM (#22238241)
You'll still be chasing pointers with these. What you (and myself and many others) are looking for are inline types[0][1] that are part of Project Valhalla[2].

[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

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
Re:Java 14 Feature Spotlight: Records by BubRoss on Tuesday February 04, 2020 @03:20PM (#22240483)
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?
Re:Java 14 Feature Spotlight: Records by lumost on Tuesday February 04, 2020 @07:41PM (#22242868)
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.
Re:Java 14 Feature Spotlight: Records by BubRoss on Tuesday February 04, 2020 @08:12PM (#22243059)
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.
Re:Java 14 Feature Spotlight: Records by abraxas on Tuesday February 04, 2020 @12:24PM (#22238257)
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.
Re:Java 14 Feature Spotlight: Records by xxs on Tuesday February 04, 2020 @02:07PM (#22239648)
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.
Re:Java 14 Feature Spotlight: Records by abraxas on Tuesday February 04, 2020 @07:11PM (#22242621)
Yes there is also the sun.misc.Unsafe class but of course that's skating on thin ice.
Re:Java 14 Feature Spotlight: Records by dman on Tuesday February 04, 2020 @01:35PM (#22239217)
That ship has sailed.
Re:Java 14 Feature Spotlight: Records by abraxas on Tuesday February 04, 2020 @07:12PM (#22242627)
What do you mean?
Re:Java 14 Feature Spotlight: Records by dman on Wednesday February 05, 2020 @02:25PM (#22250162)
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.