DEV Community

Discussion on: Data-Oriented programming: Liberate yourself from objects

Collapse
 
macsikora profile image
Pragmatic Maciej

Interesting trick, as too many books have functional programming in name, you made the name different - data oriented programming, what looks different, where in real ain't ;)

Collapse
 
viebel profile image
Yehonathan Sharvit

If you read the book you'll learn what is the difference between DOP and FP.

Collapse
 
polymathsomnath profile image
Somnath Singh

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.