DEV Community


Discussion on: Why I don't believe in pure functional programming anymore

functional_js profile image
Functional Javascript • Edited

Thanks for sharing your experience Ryan.

This is my take on FP (Functional Programming)...

I think it's important to separate "pure", or "theoretical" or "academic" FP from "practical FP"

Practical FP you can do in pretty much any language.
A lot of it involves using only a minimal subset of a language, so the major construct that you're left with is the Function.

Here's what I don't use in JavaScript...

  • Practical FP means thinking in terms of functions.
  • Thinking of solving problems by composing functions.
  • Wrapping details away in functions.
  • Keep your functions free (not a member of an object), thus separating data from behavior.
  • Free functions don't mean they are pure; Pure functions I call "utility functions", and they're put into utility files.
  • Mutability isn't something you avoid, it's something you formally manage.
  • One of the many great things about FP is that it's great for writing pseudocode. You can design easily with FP pseudocode.

Here's a functional pipeline pseudocode example, which is pretty much all mutation...

const p1 = pipe(