/Notes/ Functional Programming

What’s functional programming?

  • Treats computation as the evaluation of mathematical functions and avoids changing state, avoids mutable data
  • Declarative paradigm
    • programming done with expressions or declarations instead of statements
  • Declarative programming
    • expresses the logic of a computation without describing its control flow
    • like asking someone to draw a landscape, you don’t care how, it’s up to them
  • Imperative programming
    • uses statements to change a program’s state
    • like your friend listening to Bob Ross tell them how to paint a landscape, step-by-step instructions
  • Pure functions
    • return a value solely based on what was passed into it
    • doesn’t modify values outside of its scope
    • never mutates data, produces no side effects, can be easily reused
Written on October 30, 2019