3 ms·
That article is naive. It assumes that C/C++ developers concerned with performance write object-oriented code. They do not. They write data-oriented code. M
by pkaler 16y ago
That article is naive. It assumes that C/C++ developers concerned with performance write object-oriented code. They do not. They write data-oriented code.
Most of the multi-threading issues go away. This is how fast code is written for the Cell processor in the Sony PS3.
Most malloc/free issues go away. Most data is a value type or has an explicit lifetime (game-lifetime, mission-lifetime, frame-lifetime for the game development case).
More information on data-oriented design: http://gamesfromwithin.com/data-oriented-design http://gamesfromwithin.com/data-oriented-design
- blinkingled 16y agoI didn't read through the link fully but it sounds to me like after changing the way you program you can get C++ to deliver the kind of performance a JVM gives you without doing anything special? Or are you saying with data-oriented programming C++ becomes significantly faster than Java? To the extent that most people aren't going to change their programming methodology just to avoid Java and C++ still has its niche usages - I don't think the article is naive in any way.
- pkaler 16y agoData-oriented programming produces programs that are a magnitude faster than object-oriented programs. It's the same difference as stateful vs stateless code. And it's the same difference as RESTful APIs vs RPC. 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.
- repsilat 16y ago> 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.