What is Data Oriented programming?

wizzardz picture wizzardz · Nov 8, 2010 · Viewed 19.2k times · Source

Can any one explain to me

  1. what is Data Oriented programming?
  2. Is Data oriented programming and functional programming the same?
  3. How is Data Oriented programming different from Object Oriented programming?
  4. Under what circumstances do we choose Data Oriented programming languages over Object Oriented programming languages?

Answer

mani3xis picture mani3xis · May 9, 2011

First I want to say, that Data-oriented design and Data-driven programming is not the same!

In object-oriented programming you are focusing on a single object (class - its methods, members, etc.). In data-oriented design you are thinking how data is touched and processed. You just have a box that processes your input data to your output data (the ideal input data is the same as output).

All this was created to write high-performance applications. You are working on homogeneous, linear data - all to take the full advantage of CPU cache (both instruction and data).

Whenever you can, try to avoid hierarchical structures (use arrays instead), try to write functions that works on multiple data and use hot and cold structure splitting.

int Foo(int* input_data, int count)
{
    // do something with your data
}