Programing Language: Jargon Lambda in Decline (2013)
What is Lambda
lambda, is the traditional name for the more logical name of function expression. It is a value. The value represents a function. It can be assigned to variable, and function can also return function expression.
Lambda is also known as:
- lambda. (in most lisp language and early languages.)
- anonymous function. (because function expression is not named function.)
- pure function. (used in Wolfram Language, to distinguish function defined using symbolic pattern matching.)
- function expression. (logical name in context of programing languages.)
- function. (in modern languages, often the language's definition of function/subroutine is just function expression.)
The name lambda came from from “lambda calculus”, a study of math foundation modeled after the math concept of function, by means of string replacement. The greek letter lambda λ happens to be the symbol used for function.
Here is example of lambda.
We try to have a function that just add 1 f(x) = x+1, and evaluate this function at 4, result in 5.
(funcall (lambda (x) (+ x 1)) 4) ;; 5
print ( (lambda x:x+1)(4) ) # 5
console.log((function (x) { return x + 1; })(4)); // 5 // or console.log(((x) => x + 1)(4)); // 5
(fun x -> x + 1) 3;; (* 4 *)
Jargon Lambda in Decline
these days, with functional programing getting popular, and lots lots new languages, the lambda name is falling out of fashion, and i think that's a good thing.
for example, in JavaScript, its functions are lambdas (For example, function () {…}), but no JavaScript literature calls it lambda. [see Functional Programing in JavaScript]. Younger generation using these languages, never thought about lambda, yet they benefit from what these so-called “anonymous” function provides. The name lambda actually hampers understanding.
in Mathematica, the lambda is called Pure Function, and is written simply as Function[…], no lambda is ever mentioned in the one thousand plus page of Wolfram Language documentation. (it's called Pure Function to differentiate from functions defined using pattern matching.
[see Intro to Wolfram Language Pattern Matching for Lisp Coders (2008)]) Mathematica has been that way since version 1 in 1988.
the most important thing about lambda, isn't any advanced use, such as “closure”, or things one hear from the Haskell world. It's simply that the function is a expression, namely it returns a value that represents the function. (and therefore, it can be assigned to a variable, or passed as a parameter to other function, or returned as a value from a function) (here, in lisp world it's sometimes known as “Function as First Class Citizens”. (again, a phrase that harms education and propagation of functional languages))