Tacit programming
Encyclopedia
Tacit programming is a programming paradigm
Programming paradigm
A programming paradigm is a fundamental style of computer programming. Paradigms differ in the concepts and abstractions used to represent the elements of a program and the steps that compose a computation A programming paradigm is a fundamental style of computer programming. (Compare with a...

 in which a function definition does not include information regarding its arguments
Parameter (computer science)
In computer programming, a parameter is a special kind of variable, used in a subroutine to refer to one of the pieces of data provided as input to the subroutine. These pieces of data are called arguments...

, using combinators
Combinator library
A combinator library is a software library which implements combinators for a functional programming language; "the key idea is this: a combinator library offers functions that combine functions together to make bigger functions"...

 and function composition
Function composition (computer science)
In computer science, function composition is an act or mechanism to combine simple functions to build more complicated ones...

 (but not λ-abstraction) instead of variable
Variable (programming)
In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...

s. The simplicity behind this idea allows its use on several programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

s, such as J programming language and APL and especially in stack
Stack-oriented programming language
A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....

 or concatenative
Concatenative programming language
A concatenative programming language is a point-free programming language in which all expressions denote functions and the juxtaposition of expressions denotes function composition...

 languages, such as PostScript
PostScript
PostScript is a dynamically typed concatenative programming language created by John Warnock and Charles Geschke in 1982. It is best known for its use as a page description language in the electronic and desktop publishing areas. Adobe PostScript 3 is also the worldwide printing and imaging...

, Forth, Joy, and Factor
Factor (programming language)
Factor is a stack-oriented programming language created by Slava Pestov. Factor is dynamically typed and has automatic memory management, as well as powerful metaprogramming features. The language has a single implementation featuring a self-hosted optimizing compiler and an interactive development...

. Outside of the APL and J communities, tacit programming is referred to as point-free style, or more pithily as pointless programming, because of the lack of explicit arguments, or "points."

The key idea in tacit programming is to assist in operating at the appropriate level of abstraction. That is, to translate the natural transformation
Natural transformation
In category theory, a branch of mathematics, a natural transformation provides a way of transforming one functor into another while respecting the internal structure of the categories involved. Hence, a natural transformation can be considered to be a "morphism of functors". Indeed this intuition...

 given by currying
Currying
In mathematics and computer science, currying is the technique of transforming a function that takes multiple arguments in such a way that it can be called as a chain of functions each with a single argument...

:
into computer functions, where the left represents the uncurried form of a function and the right the curried. hom(X,Y) denotes the homomorphism
Homomorphism
In abstract algebra, a homomorphism is a structure-preserving map between two algebraic structures . The word homomorphism comes from the Greek language: ὁμός meaning "same" and μορφή meaning "shape".- Definition :The definition of homomorphism depends on the type of algebraic structure under...

s from X to Y while, A x B denotes the Cartesian product
Cartesian product
In mathematics, a Cartesian product is a construction to build a new set out of a number of given sets. Each member of the Cartesian product corresponds to the selection of one element each in every one of those sets...

 of A and B.

Functional programming

A simple example (in Haskell
Haskell (programming language)
Haskell is a standardized, general-purpose purely functional programming language, with non-strict semantics and strong static typing. It is named after logician Haskell Curry. In Haskell, "a function is a first-class citizen" of the programming language. As a functional programming language, the...

) is a program which takes a sum of a list. A programmer might define a sum recursively using a pointed (cf. value-level programming
Value-level programming
Value-level programming refers to one of the two contrasting programming paradigms identified by John Backus in his work on Programs as mathematical objects, the other being function-level programming...

) method as:

sum (x:xs) = x + sum xs
sum [] = 0

However by noting this is a fold
Fold (higher-order function)
In functional programming, fold – also known variously as reduce, accumulate, compress, or inject – are a family of higher-order functions that analyze a recursive data structure and recombine through use of a given combining operation the results of recursively processing its...

 the programmer could replace this with:

sum xs = foldr (+) 0 xs

and then the argument is not needed so this can be replaced with

sum = foldr (+) 0

which is point-free.

Another example is the use of the dot
Function composition (computer science)
In computer science, function composition is an act or mechanism to combine simple functions to build more complicated ones...

 operator:

p x y z = f (g x y) z

we can simply group

f (g x y) z ≡ f ((g x) y) z ≡ (f .) (g x) y z ≡ ((f .) . g) x y z

so

p = (f .) . g


Finally to see a complex example imagine a map filter program which takes a list, applies a function to it, and then filters the elements based on a criterion

mf criteria operator list = filter criteria (map operator list)

can be expressed point-free as

mf = (. map) . (.) . filter

APL family

In J
J (programming language)
The J programming language, developed in the early 1990s by Kenneth E. Iverson and Roger Hui, is a synthesis of APL and the FP and FL function-level languages created by John Backus....

 one can see the same sort of point-free code in a function designed to compute the average of a list (array) of numbers:
avg=: +/ % #
# counts the number of items in the array. +/ sums the items of the array. % divides the sum by the number of items

Stack-based

In stack-oriented programming language
Stack-oriented programming language
A stack-oriented programming language is one that relies on a stack machine model for passing parameters. Several programming languages fit this description, notably Forth, RPL, PostScript, and also many Assembly languages ....

s (and concatenative ones
Concatenative programming language
A concatenative programming language is a point-free programming language in which all expressions denote functions and the juxtaposition of expressions denotes function composition...

, most of which are stack based), point-free methods are commonly used. For example a procedure to compute the Fibonacci number
Fibonacci number
In mathematics, the Fibonacci numbers are the numbers in the following integer sequence:0,\;1,\;1,\;2,\;3,\;5,\;8,\;13,\;21,\;34,\;55,\;89,\;144,\; \ldots\; ....

s might look like:

/fib
{
dup dup 1 eq exch 0 eq or not
{
dup 1 sub fib
exch 2 sub fib
add
} if
} def

See also

  • Combinatory logic
    Combinatory logic
    Combinatory logic is a notation introduced by Moses Schönfinkel and Haskell Curry to eliminate the need for variables in mathematical logic. It has more recently been used in computer science as a theoretical model of computation and also as a basis for the design of functional programming...

  • Concatenative programming language
    Concatenative programming language
    A concatenative programming language is a point-free programming language in which all expressions denote functions and the juxtaposition of expressions denotes function composition...

  • Function-level programming
    Function-level programming
    In computer science, function-level programming refers to one of the two contrasting programming paradigms identified by John Backus in his work on programs as mathematical objects, the other being value-level programming....

  • Joy (programming language), modern highly tacit language

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK