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
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 to create two records Book2
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