Object
Functional

Why?

Functional programming is an approach to software development based around the evaluation of functions. Like mathematics, functions in programming map input to output to produce a result. You can combine basic functions in many ways to build more and more complex programs.

Functional programming follows a few core principles:

  • Functions are independent from the state of the program or global variables. They only depend on the arguments passed into them to make a calculation
  • Functions try to limit any changes to the state of the program and avoid changes to the global objects holding data
  • Functions have minimal side effects in the program
  • The functional programming software development approach breaks a program into small, testable parts.

Functional programming is a style of programming where solutions are simple, isolated functions, without any side effects outside of the function scope.

INPUT -> PROCESS -> OUTPUT

Functional programming is about:

  1. Isolated functions - there is no dependence on the state of the program, which includes global variables that are subject to change
  2. Pure functions - the same input always gives the same output
  3. Functions with limited side effects - any changes, or mutations, to the state of the program outside the function are carefully controlled

Why?

Functional programming is an approach to software development based around the evaluation of functions. Like mathematics, functions in programming map input to output to produce a result. You can combine basic functions in many ways to build more and more complex programs.

Functional programming follows a few core principles:

  • Functions are independent from the state of the program or global variables. They only depend on the arguments passed into them to make a calculation
  • Functions try to limit any changes to the state of the program and avoid changes to the global objects holding data
  • Functions have minimal side effects in the program
  • The functional programming software development approach breaks a program into small, testable parts.

Functional programming is a style of programming where solutions are simple, isolated functions, without any side effects outside of the function scope.

INPUT -> PROCESS -> OUTPUT

Functional programming is about:

  1. Isolated functions - there is no dependence on the state of the program, which includes global variables that are subject to change
  2. Pure functions - the same input always gives the same output
  3. Functions with limited side effects - any changes, or mutations, to the state of the program outside the function are carefully controlled

how is it different from imperative?

  • in english, imperative tense means giving commands
  • imperative programming means, giving computer set of statements to perfom task
    • often statements change state of prog, like updating global var
    • ex> for loop, that gives exact direction to iterate over indices of array
  • functional programming is declarative form of programming
    • you tell computer what you want done by calling a method
    • ex> map() method that can iterate over array w/o worrying about indexes

fp focuses on what. imperative focuses on how

how is it different from imperative?

  • in english, imperative tense means giving commands
  • imperative programming means, giving computer set of statements to perfom task
    • often statements change state of prog, like updating global var
    • ex> for loop, that gives exact direction to iterate over indices of array
  • functional programming is declarative form of programming
    • you tell computer what you want done by calling a method
    • ex> map() method that can iterate over array w/o worrying about indexes

fp focuses on what. imperative focuses on how