Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I’m not sure if I’m missing something, but isn’t this basically just the same as Java 7’s Buffer, ByteBuffer, etc?

These, too, support the same types of backing memory (backed by native memory, stack-allocated memory, or a Java array), same access pattern, etc, and are also used by many third-party libraries now for such stuff (including many networking libraries, and graphics libraries such as LWJGL3)

What’s so innovative about these?



> I’m not sure if I’m missing something, but isn’t this basically just the same as Java 7’s Buffer, ByteBuffer, etc?

Aren't those Java types heap-allocated and GC managed? I think the big deal is that Span can be allocated anywhere (native, stack, heap).


Nope, the wrapper is, but a ByteBuffer also allows different allocation strategies, which is how different libraries use them.

For example, LWJGL3 has a separate stack where it allocates them.


There is no way to use stack allocated memory in Java.

LWJGL's MemoryStack emulates a C style stack by preallocating a set amount of off-JVM-heap memory and decrementing/incrementing an index into it.


> There is no way to use stack allocated memory in Java.

Not directly, but most JIT compilers do it.

It is tricky and fragile, but one can make use of the JIT logs and try to re-write the code so that it takes the right decision regarding escape analysis.

As for an actual support at language level, we need to wait for the outcome of projects Valhalla and Panama.


> LWJGL's MemoryStack emulates a C style stack by preallocating a set amount of off-JVM-heap memory and decrementing/incrementing an index into it.

So do all relevant game engines. Having a separate memorystack from the actual one for game objects is basically standard.


> What’s so innovative about these?

Not all improvements have to be innovative. The most mundane things can vastly improve the pleasure of using a language. Considering that array slicing originated in Fortran, Buffer is hardly innovative - yet, as you've pointed out, it has been a huge benefit for Java developers.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: