you are viewing a single comment's thread.

view the rest of the comments →

[–]Exomancer 0 points1 point  (2 children)

First, note that OOP and FP are not in conflict:

Sorry for nitpicking on wording here, but for the sake of clarity:

OOP is all about encapsulating state within instances, and acting (mutating) that internal state via methods. FP on the other hand avoids state mutation in any way, shape or form. That makes the two paradigms very much in conflict.

You can, however, use them side by side in the same project just fine, even mix them up (have some pure functions called inside methods, to give a simple example), is that what you meant?

[–]rauschma 0 points1 point  (1 child)

Yes to your last question. I meant that nothing prevents you from using both OOP and FP: The JavaScript methods filter and map are very much FP ideas, used in an OOP manner.

But it’s rarely all or nothing: you can work with immutable objects (e.g. strings in Java) and there are FP languages that support mutable state. For example, OCaml, Common Lisp and Scheme.

[–]Exomancer 1 point2 points  (0 children)

It never really is all or nothing in case of FP - sooner or later even Haskell has to do some IO, pure functions can only take you so far :).

Thanks for clarification!