I've been playing with other languages recently. It's been fun but there are some terms that keep popping up that are worth noting.
Functional Programming
Dan Grossman of the University of Washington emphasises that functional programming:
In addition, it "often uses lots of recursions. You often use a style that is more mathematical than other styles of programming." [2] Although it is not sufficient to say that it is anything that is not OOP.
First Class Functions
Are "a situation where functions can appear and be used wherever we use other values like numbers and lists and strings. Functions can be argument to other functions, combined with tuples and so on" [2]
First Order Functions
The most common use of First Class Functions is as an argument/result of another function. This other function is called a higher-order function. [2] All other functions are called first order functions [3].
Lexically scoped
"We use the environment where the function was defined not the environment in which it is being called" [2].
Closures
"The language keeps around those old environments so that it can implement lexical scope properly... So, a function value has two parts ... the code part [and] the environment that was current when the function was defined... This thing is called a closure." [2]
Total Order
"This is a binary relation ≤ that satisfies:
Antisymmetry: if v ≤ w and w ≤ v then v = w
Transitivity: if v ≤ w and w ≤ v then v ≤ x
Totality: either v ≤ w or w ≤ v or both
Note: the <= for double is not a total order." [1] Eg,
assertTrue(1d <= 1d);
assertTrue(0.1d <= 0.1d);
assertTrue(Double.NaN <= Double.NaN); // blow up!
[1] Prof Bob Segdewick, Princeton University.
[2] Prof Dan Grossman, Coursera.
[3] Wikipedia.
Functional Programming
Dan Grossman of the University of Washington emphasises that functional programming:
- Avoids mutation
- Uses functions as values
In addition, it "often uses lots of recursions. You often use a style that is more mathematical than other styles of programming." [2] Although it is not sufficient to say that it is anything that is not OOP.
First Class Functions
Are "a situation where functions can appear and be used wherever we use other values like numbers and lists and strings. Functions can be argument to other functions, combined with tuples and so on" [2]
First Order Functions
The most common use of First Class Functions is as an argument/result of another function. This other function is called a higher-order function. [2] All other functions are called first order functions [3].
Lexically scoped
"We use the environment where the function was defined not the environment in which it is being called" [2].
Closures
"The language keeps around those old environments so that it can implement lexical scope properly... So, a function value has two parts ... the code part [and] the environment that was current when the function was defined... This thing is called a closure." [2]
Total Order
"This is a binary relation ≤ that satisfies:
Antisymmetry: if v ≤ w and w ≤ v then v = w
Transitivity: if v ≤ w and w ≤ v then v ≤ x
Totality: either v ≤ w or w ≤ v or both
Note: the <= for double is not a total order." [1] Eg,
assertTrue(1d <= 1d);
assertTrue(0.1d <= 0.1d);
assertTrue(Double.NaN <= Double.NaN); // blow up!
[1] Prof Bob Segdewick, Princeton University.
[2] Prof Dan Grossman, Coursera.
[3] Wikipedia.