HACKER Q&A
📣 viebel

Data-Oriented programming vs. Functional programming


The main difference between Data-Oriented programming and Functional Programming is about how we represent data inside a program. What are the pros and cons of each approach?


  👤 nudpiedo Accepted Answer ✓
You should add Ask HN to the title, and still I think your question may be better posted at stackoverfow or similar places rather than this forum.

👤 mamcx
No.

The specific structure can be part, but the difference is exactly as is on the name.

Niklaus Wirth say:

   Algorithms + Data Structures = Programs
Most paradigms pay a bigger attention to the "Algorithms" side. And data is a distant second class citizen.

"Functional Programming" is about functions. All discussions are centerer in the algorithms related to it.

"Object oriented" is about objects. All discussions are centerer in the algorithms related to it.

But this is distracting:

    Show me your flowcharts, and conceal your tables, and I shall continue to be mystified; show me your tables and I won’t usually need your flowcharts: they’ll be obvious.
Fred Brooks

That is why a lot of people get drown in abstractions, instead of solve what the problem is.

---

Now, if we instead make data the driver of the decisions a lot of things can be simplified. A common example is when we ditch "abstracting-away" ORMs and just use SQL (that is data oriented), because hide/not use at full what a RDBMS is moronic.

----

But both are part of the same coin. So if data become truly important, WHICH algorithms fit it better?

This is where become easier to work on data with structural comparisons, immutability, etc. Is in fact a relational way of think, just with other names and probably a small part of it.

---

Now the answer is more like "yes" because focus in how represent data is actually big part of the deal, but that still can make some to get carry away by the algorithms of it, like get too focused in make use of persistent structures instead of exactly think on HOW to represent the data that allow the best way to manipulate it.


👤 django77
I don't think FP has anything to do with how data is represented, it's more related to how we operate on that data.

👤 mcphage
What do you feel are the differences in how data is represented between the two?

👤 amboo7
How about trying to define both first? I am not sure what data-oriented means.

👤 arcanon
You should probably be less into philosophy and categorizing and more into building shit. Go watch some Feynman and then try to get something to work on the gpu