Re:For processing strings, streams in C++ can be slow
by simiones on Thursday December 07, 2023 @08:39AM
(#38556126)
That's true. It's also important to note that this feature of C++ actually breaks encapsulation - the size of an object, including all of its private fields, private parent classes etc, is part of the public interface of the object in C++. So whenever you add a new private field to an object, you need to recompile all uses of your class, even if your class is used through a DLL.
Deep down the problem could be rephrased as "there are no structs in Java". In C# for example you could have a vector of structs and enjoy linear memory access.