News for hackers. Stuff that matters.
Re:Major standard library changes in Go 1.20 by kaba0 on Tuesday January 17, 2023 @02:56AM (#34410141)
> why you might not want to use byte[]

Such as? Java buffers use byte arrays by default as underlying storage.

Re:Major standard library changes in Go 1.20 by klodolph on Tuesday January 17, 2023 @05:49AM (#34411086)
https://docs.oracle.com/javase/7/docs/api/java/nio/ByteBuffe...

Look for "Direct vs. non-direct buffers". Some buffers are backed by arrays, some are not.

You're basically deciding whether you are okay with a higher cost for I/O or a higher-cost for interacting with the data in the buffer.

Re:Major standard library changes in Go 1.20 by kaba0 on Tuesday January 17, 2023 @07:50AM (#34411818)
I do know about it, I was trying to find out what difference do the parent mean between Go’s byte arrays and Java’s solution(s).

Also, I fail to get your conclusion — direct buffers only have a higher cost for initialization/dealloc otherwise reading/writing should be as cheap as it gets. Byte buffers on the other hand do get write barriers but that is also unlikely to be hit that often (and I believe larger byte arrays get allocated in a separate region that doesn’t get moved).