Glossary of Terms - Functional Programming in JavaScript (2015)

Functional Programming in JavaScript (2015)

Appendix B. Glossary of Terms

This appendix covers some of the important terms that are used in this book:

· Anonymous function: A function that has no name and is not bound to any variables. It is also known as a Lambda Expression.

· Callback: A function that can be passed to another function to be used in a later event.

· Category: In terms of Category Theory, a category is a collection of objects of the same type. In JavaScript, a category can be an array or object that contains objects that are all explicitly declared as numbers, strings, Booleans, dates, objects, and so on.

· Category Theory: A concept that organizes mathematical structures into collections of objects and operations on those objects. The data types and functions used in computer programs form the categories used in this book.

· Closure: An environment such that functions defined within it can access local variables that are not available outside it.

· Coupling: The degree to which each program module relies on each of the other modules. Functional programming reduces the amount of coupling within a program.

· Currying: The process of transforming a function with many arguments into a function with one argument that returns another function that can take more arguments, as needed. Formally, a function with N arguments can be transformed into a function chain of N functions, each with only one argument.

· Declarative programming: A programming style that expresses the computational logic required to solve the problem. The computer is told what the problem is rather than the procedure required to solve it.

· Endofunctor: A functor that maps a category to itself.

· Function composition: The process of combining many functions into one function. The result of each function is passed as an argument to the next, and the result of the last function is the result of the whole composition.

· Functional language: A computer language that facilitates functional programming.

· Functional programming: A declarative programming paradigm that focuses on treating functions as mathematical expressions and avoids mutable data and changes in state.

· Functional reactive programming: A style of functional programming that focuses on reactive elements and variables that change over time in response to events.

· Functor: A mapping between categories.

· Higher-order function: A function that takes either one or more functions as input, and returns a function as its output.

· Inheritance: An object-oriented programming capability that allows one class to inherit member variables and methods from another class.

· Lambda expressions: See Anonymous function.

· Lazy evaluation: A computer language evaluation strategy that delays the evaluation of an expression until its value is needed. The opposite of this strategy is called eager evaluation or greedy evaluation. Lazy evaluation is also known as call by need.

· Library: A set of objects and functions that have a well-defined interface that allows a third-party program to invoke their behavior.

· Memoization: The technique of storing the results of expensive function calls. When the function is called later with the same arguments, the stored result is returned rather than computing the result again.

· Method chain: A pattern in which many methods are invoked side by side by directly passing the output of one method to the input of the next. This avoids the need to assign the intermediary values to temporary variables.

· Mixin: An object that can allow other objects to use its methods. The methods are intended to be used solely by other objects, and the mixin object itself is never to be instantiated.

· Modularity: The degree to which a program can be broken down into independent modules of code. Functional programming increases the modularity of programs.

· Monad: A structure that provides the encapsulation required by functors.

· Morphism: A pure function that only works on a certain category and always returns the same output when given a specific set of inputs. Homomorphic operations are restricted to a single category, while polymorphic operations can operate on multiple categories.

· Partial application: The process of binding values to one or more arguments of a function. It returns a partially applied function, which in turn accepts the remaining, unbound arguments.

· Polyfill: A function used to augment prototypes with new functions. It allows us to call our new functions as methods of the previous function.

· Pure function: A function whose output value depends only on the arguments that are the input to the function. Thus, calling a function, f, twice with the same value of an argument, x, will produce the same result, f(x),every time.

· Recursive function: A function that calls itself. Such functions depend on solutions to smaller instances of the same problem to compute the solution to the larger problem. Like iteration, recursion is another way to repeatedly call the same block of code. But, unlike iteration, recursion requires that the code block define the case in which the repeating code calls should terminate, known as the base case.

· Reusability: The degree to which a block of code, usually a function in JavaScript, can be reused in other parts of the same program or in other programs.

· Self-invoking function: An anonymous function that is invoked immediately after it has been defined. In JavaScript, this is achieved by placing a pair of parentheses after the function expression.

· Strategy pattern: A method used to define a family of interchangeable algorithms.

· Tail recursion: A stack-based implementation of recursion. For every recursive call, there is a new frame in the stack.

· Toolkit: A small software library that provides a set of functions for the programmer to use. Compared to a library, a toolkit is simpler and requires less coupling with the program that invokes it.

· Trampolining: A strategy for recursion that provides tail-call elimination in programming languages that do not provide this feature, such as JavaScript.

· Y-combinator: A fixed-point combinator in Lambda calculus that eliminates explicit recursion. When it is given as input to a function that returns a recursive function, the Y-combinator returns the fixed point of that function, which is the transformation from the recursive function to a non-recursive function.