32 ms·
Ask HN: 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 6y agoYou 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.
- viebel 6y agoDone
- django77 6y agoI don't think FP has anything to do with how data is represented, it's more related to how we operate on that data.
- viebel 6y agoDOP and FP share common insights about separation between code and data and constraining ourselves to immutable data. The main difference between DOP and FP is that in DOP we use generic data structures to represent data (e.g. maps and lists)
- mcphage 6y agoWhat do you feel are the differences in how data is represented between the two?
- viebel 6y agoIn both DOP and FP data is immutable. In FP, we tend to represent data with specific types while in DOP we represent data with generic data structures (e.g. maps and lists)
- amboo7 6y agoHow about trying to define both first? I am not sure what data-oriented means.
- viebel 6y agoData-oriented programming is about representing data with immutable generic data structures (e.g. maps and lists) and manipulating data with general purpose functions
- hctaw 6y agoThat's no definition of DO I've ever heard. A list is a classic example of a non-data oriented structure! DO as I understand it is about recognizing how data is actually laid out and interacted with by a processor, as opposed to meaningful abstract relationships to a programmer. It's about breaking down costly abstractions, rather than ignoring the cost of higher level abstractions. DO exists primarily in opposition to OO, not FP. The classic example is the array of structs to struct of arrays (OO to DO transformation).
- viebel 6y agoYou are referring to Data-Oriented design, while I am referring to Data-Oriented programming https://blog.klipse.tech/visualization/2021/02/16/data-related-paradigms.html https://blog.klipse.tech/visualization/2021/02/16/data-relat...
- hctaw 6y agoPerhaps pick a better name that isn't confusing. In industry what your definition refers to is called "generic programming" if I understand correctly.
- viebel 6y agoI didn't choose the term "Data-Oriented programming" It was used by Cognitect folks to promote clojure [1] and actually it was coined by Eugene Kutznetsov in 2004 [2] As you know, naming is one of the two hard things in programming. [1]: https://www.cognitect.com/blog/2016/6/28/the-new-normal-data-leverage https://www.cognitect.com/blog/2016/6/28/the-new-normal-data... [2]: https://adtmag.com/articles/2004/08/05/data-integration-a-little-dop-might-do-you.aspx https://adtmag.com/articles/2004/08/05/data-integration-a-li...
- arcanon 6y agoYou 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
- rmorey 6y ago> You should probably be less into philosophy and categorizing and more into building shit. I need this written on a huge poster behind my desk
- mamcx 6y agoNo. 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.
- viebel 6y agoHas this data-centric approach be embraced in programming languages other than Clojure?
- threatofrain 6y agoHow is Clojure data centric in the way people are talking about here? IMO Clojure values immutability in a way which is data agnostic, not data aware. Also Clojure not emphasizing the power of types… but types emphasize programming with data awareness.
- fulafel 6y ago