Re:In what cases is Java faster than C++?
by repsilat on Wednesday February 16, 2011 @07:38PM
(#2229090)
> Data-oriented code is not possible in Java...
There are obviously techniques in data-oriented code that aren't possible in Java, but a lot of the key insight is applicable in just about every language. Structures-of-arrays, defining the data in objects based on usage patterns instead of responsibilities and "model-the-world" categorisation...
Java doesn't have a `sizeof` operator, and objects probably don't tend to store their object member variables by value, and it's not always obvious which function calls cost how much... Problems, to be sure, but if you really want data-oriented code you can usually contort yourself far enough to get it.
If you care about performance and scalability then you write stateless code and use RESTful interfaces. You also choose to write data-oriented code rather than object-oriented code.
Data-oriented code is not possible in Java because you can't create complex value types and you can't control when and where memory gets allocated and deallocated.