3 ms·
>With Java, you have to go out of your way to maintain good cache locality because you give up control over memory layout for automatic memory management. Ther
by jffhn 2y ago
>With Java, you have to go out of your way to maintain good cache locality because you give up control over memory layout for automatic memory management.
There is a shadowy cult in a hidden corner of the Java community, an heresy to many, only followed by a handful of obnoxious zealots inspired by the dark ages of Ada 83, C, or even assembly, who take pride in creating Java programs that only allocate a finite amount of objects regardless of how long you run them for, and to which the "new" keyword is a taboo which avoidable use is assimilated to blasphemy.
As a member of this sect, in a few cases of presenting some of our programs on some laptop, I've had dumbfounded observers looking around the laptop for the network cable linking it to the server they thought it must have been running on.
- gred 2y agoAh, so you're one of the six Epsilon GC users :-)
- vrighter 2y agothis is pretty much a necessity sometimes. I was writing an audio synthesizer in c# and this is exactly what I had to do. Allocate whatever I need up front and ban the new keyword from then on. Not that different to c++ had I chosen that instead.
- neonsunset 2y agoTo be fair, working with audio is great in a way that you usually know the exact size of the buffer you need, so it is easy to either stackalloc it or NativeMemory.Alloc the pointer and wrap it in a span, completely bypassing GC. The downside is there aren’t that many libraries that are up-to-date, but working with system APIs directly or e.g. PortAudio bindings is also an option.