3 ms·
I really hope this gets into Java9 http://objectlayout.org/ http://objectlayout.org/ Gives the same benefits as C structs while still behaving like Java object
by jerven 12y ago
I really hope this gets into Java9 http://objectlayout.org/ http://objectlayout.org/
Gives the same benefits as C structs while still behaving like Java objects. i.e. has the structs memory semantics while having java function/method semantics associated with the memory.
Better explained in this presentation http://medianetwork.oracle.com/video/player/3730888956001 http://medianetwork.oracle.com/video/player/3730888956001
(there are other sources as well).
- MrBuddyCasino 12y agoThats a good one, Gil Tene is really a good speaker. For anyone who (like me) thinks: "structs are just classes without methods, why are they faster?". The answer is that this is about arrays, which are currently slow in Java because they are: - mutable: elements can be changed, nulled etc. - polymorphic: they can contain T or subtype-of-T This makes fast streaming of objects impossible, because you need to deref the object. If this changes, object addresses can be calculated like in C, which makes things fast - flat memory is fast, prefetchers work their magic.