News for hackers. Stuff that matters.
Re:FlatBuffers: a memory efficient serialization library by mantraxB on Tuesday June 17, 2014 @02:13PM (#7905975)
I don't get it, you can't read anything out of a ByteBuffer, except a bunch of bytes.

You can't map 1:1 any more complicated in-memory structure to that buffer, or am I wrong?

Re:FlatBuffers: a memory efficient serialization library by kentonv on Tuesday June 17, 2014 @03:48PM (#7906560)
ByteBuffer has methods for reading primitive values of all sizes -- ints, floats, etc. -- from arbitrary offsets within the buffer. So you just need a wrapper object with nice generated methods for each field which in turn call the ByteBuffer getters.

None that the C++ code works this way too. We don't cleverly generate a struct that just happens to have the right layout; we generate a class that wraps a pointer and provides inline accessors that read/write values from the correct offset relative to that pointer. After inlining, it's just as fast.