Data-oriented design: Difference between revisions

Content deleted Content added
WikiCleanerBot (talk | contribs)
m v2.05b - Bot T20 CW#61 - Fix errors for CW project (Reference before punctuation)
Added archive, fixed citations
Line 9:
As a programming paradigm, '''data-oriented programming''' (also commonly referred to as data-oriented design), is about implementing '''transforms''' into the native language, often with [[Procedural programming|Procedural]], [[Functional programming|Functional]], and [[Array programming|Array]] programming, though not limited from [[Object-oriented programming]]. To most optimally transform data between different states, the approach is to first focus on what transforms exist and discovering what they need to operate. Second is to optimize data layouts for these transforms, separating and sorting [[field (computing)|fields]] according to when they are needed, and to think about how data flows through the transform chains.
 
In the context of [[computing]], data-oriented programming heavily benefits from [[program optimization|program optimizations]] motivated by efficient usage of the [[CPU cache]], often used in [[video game]] development<ref name=gamesfromwithin>{{cite web |last=Llopis |first=Noel |date=December 4, 2009 |title=Data-oriented design |url=http://gamesfromwithin.com/data-oriented-design |url-status=live |archive-url=https://web.archive.org/web/20190423233051/http://gamesfromwithin.com/data-oriented-design |archive-date=Apr 23, 2019 |access-date=April 17, 2020 |website=Data-Oriented Design (Or Why You Might Be Shooting Yourself in The Foot With OOP)}}</ref> and other high-performance applications, such as the [[Zig (programming language)|Zig]] compiler.<ref>{{Citation |last=Cities |first=Handmade |title=Andrew Kelley - Practical DOD |date=2021-11-23 |url=https://vimeo.com/649009599 |access-date=2023-06-01}}</ref> Proponents include Mike Acton,<ref>{{cite web|title=CppCon 2014: Mike Acton "Data-Oriented Design and C++"|website = [[YouTube]]|url=https://www.youtube.com/watch?v=rX0ItVEVjHc}}</ref> [[Scott Meyers]],<ref>{{cite web|title=code::dive conference 2014 - Scott Meyers: Cpu Caches and Why You Care|website = [[YouTube]]|url=https://www.youtube.com/watch?v=WDIkqP4JbkE}}</ref> [[Jonathan Blow]], and [[Andrew Kelley (computer programmer)|Andrew Kelley]]. The [[parallel array]] (or [[structure of arrays]]) is a commonly referenced example of one such cache-motivated data structure. It is contrasted with the ''array of structures'' typical of object-oriented designs, and eventually balanced to a structure of arrays of structures.
 
== Computing motives ==
Line 16:
== Contrast with object orientation ==
{{Original research section|date=September 2021}}
The claim is that traditional [[object-oriented programming]] (OOP) results in poor data locality,{{Clarify|reason=What? Sorry, but OOP doesn't have to do anything with data layouts or design. Data are instances of the Objects and can be organized irrelevantly to OOP itself. The whole paragraph make no sense.|date=September 2021}} more so if runtime [[Polymorphism (computer science)|polymorphism]] ([[dynamic dispatch]]) is used (which is especially problematic on some processors).<ref>{{cite web|title=What's wrong with Object-Oriented Design? Where's the harm in it?|url=http://www.dataorienteddesign.com/dodmain/node17.html}}describes the problems with virtual function calls, e.g., i-cache misses</ref><ref>{{cite web|titlename=Data-oriented design - why you might be shooting yourself in the foot with OOP|url=http://gamesfromwithin.com/data-oriented-design}}</ref> Although OOP appears to "organize code around data", it actually organizes [[source code]] around the interaction of [[data type]]s and their relationships, rather than physically grouping individual fields and arrays in an efficient format for access by specific procedures. Moreover, it often hides layout details under [[abstraction layer]]s, while data orientation wants to consider this first and foremost.
 
== See also ==