• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Data-Oriented Programming: How is it different from FP?

 
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good day,

How is DOP different from FP, and what are the reasons to choose DOP over FP when building an application?
Also, some of the code examples uses hash maps. Is that a code smell called Primitive Obsession?


Regards,
Joey
 
Ranch Hand
Posts: 144
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If FP refers to Functional Programming...

I think the concerns of DOP and FP are different. Maybe the comparison would be more OOP to FP.
As stated in the book's page at Manning, seems that the DOP aims to separate code and data to simplify state management and eases concurrency.

But I'm sure Yehonathan would clarify it better.
 
Author
Posts: 24
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main difference between DOP and FP is about how we treat data.

In most FP languages (e.g. OCaml, Haskell), data is statically typed. As a consequence, data access is not flexible. Whereas in DOP, data can be manipulated via generic functions.

For instance, in DOP one could write a function renameKeys that rename some fields in a record. This function would work with any record e.g. a Book or a User.

In traditional FP, one would have to write two separate functions renameKeysInBook and renameKeysInUser and to create two records Book2 and User2 with the new keys.

In traditional FP, field names compile away where in DOP fields are first-class citizens.

You can read more about the conceptual approach to information in this article.
 
Jose Samonte
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you for the explanation.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic