ArticleslgStudy

science

Tacit programming

Tacit programming is a science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Tacit programming rather than just read about it. In short: Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments (or "points") on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments.

Key takeaways

  • Tacit programming belongs to science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Tacit programming to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Tacit programming from memory before moving on to harder problems.

Reference excerpt

Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments (or "points") on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments. Tacit programming is of theoretical interest, because the strict use of composition results in programs that are well adapted for equational reasoning. It is also the natural style of some programming languages, including APL and its derivatives, and concatenative languages such as Forth. The lack of argument naming gives point-free style a reputation of being needlessly obscure, hence the epithet "pointless style". Unix scripting uses the paradigm with pipes.

Examples

Python Tacit programming can be illustrated with the following Python code. A sequence of operations such as the following:

... can be written in point-free style as the composition of a sequence of functions, without parameters:

For a more complex example, the Haskell code p = ((.) f) . g can be translated as:

p = partial(compose, partial(compose, f), g)

Functional programming A simple example (in Haskell) is a program which computes the sum of a list of numbers. We can define the sum function recursively using a pointed style (cf. value-level programming) as:

However, using a fold, this can be replaced with:

And then the argument is not needed, so this simplifies to

which is point-free. Another example uses function composition:

The following Haskell-like pseudocode exposes how to reduce a function definition to its point-free equivalent:

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

It can be expressed point-free as

As suggested already, the points in point-free refer to the arguments, not to the use of dots; a common misconception. A few programs have been written to automatically convert a Haskell expression to a point-free form.

APL family In the language J, the same sort of point-free code occurs in a function made to compute the average of a list (array) of numbers:

+/ sums the items of the array by mapping (/) summation (+) to the array. % divides the sum by the number of elements (#) in the array. Euler's formula eix=cos⁡x+isin⁡x, expressed tacitly:

(j. is a primitive function whose monadic definition is 0j1 times x and whose dyadic definition is x+0j1×y.) The same tacit computations expressed in Dyalog APL:

Stack-based In stack-oriented programming languages (and concatenative ones, most of which are stack based), point-free methods are commonly used. For example, a procedure to compute the Fibonacci numbers might look like the following in PostScript:

Pipelines

Unix pipeline

In Unix scripting the functions are computer programs which receive data from standard input and send the results to standard output. For example,

sort | uniq -c | sort -rn

is a tacit or point-free composition which returns the counts of its arguments and the arguments, in the order of decreasing counts. The sort and uniq are the functions, the -c and -rn control the functions, but the arguments are not mentioned. The pipe | is the composition operator. Due to the way pipelines work, it is normally possible only to pass one argument at a time in the form of a pair of standard input/output stream. Although extra file descriptors can be opened from named pipes, this no longer constitutes a point-free style.

jq jq is a JSON-oriented programming language in which the | symbol is used to connect filters to form a pipeline in a familiar way. For example:

[1,2] | add

evaluates to 3. A literal JSON array is a jq filter that evaluates to an array. Although similar to Unix pipelines, jq pipelines allow the incoming data to be sent to more than one recipient on the RHS of the | as though in parallel. For example, the program add/length will compute the average of the numbers in an array, so that:

[1,2] | add/length

evaluates to 1.5 Similarly:

[1,2] | [length, add, add/length]

evaluates to [2,3,1.5] A dot (.) can be used to define an attachment point on the RHS, e.g.:

1 | [., .]

evaluates to [1,1] and similarly:

2 | pow(.; .)

evaluates to 4 since pow(x;y) is x to the power y.

Fibonacci sequence A tacit jq program for generating the Fibonacci sequence would be:

[0,1] | recurse( [last, add] ) | first

Here, [0,1] is the initial pair to be taken as the first two items in the Fibonacci sequence. (The pair [1,1] could likewise be used for the variant definition.) The alphabetic tokens are built-in filters: `first` and `last` emit the first and last elements of their input arrays respectively; and recurse(f) applies a filter, f, to its input recursively. jq also allows new filters to be defined in a tacit style, e.g.:

def fib: [0,1] | recurse( [last, add] ) | first;

Composition of unary functions In the section on Python in this article, the following Python definition is considered:

In point-free style, this can be written in Python as:

example = compose(foo, bar, baz)

In jq, the equivalent point-free definition would be:

def example: foo | bar | baz;

See also Combinatory logic Concatenative programming language Function-level programming Joy (programming language), modern highly tacit language

References

External links From Function-Level Programming to Pointfree Style Pure Functions in APL and J How to use tacit programming in any APL-like language Closed applicative languages 1971 - 1976 ff, in John W. Backus (Publications)

Worked examples

Example 1 — a first encounter with Tacit programming

Start with the simplest possible case. Write down what Tacit programming claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Tacit programming before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Tacit programming ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Tacit programming

In research
Tacit programming appears in science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Tacit programming in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Tacit programming is common in secondary-school and first-year university syllabi. It links to neighbouring topics Programming language comparisons, Programming paradigms, so understanding it makes those chapters shorter.
In everyday life
Look for Tacit programming outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Tacit programming” →

How to study Tacit programming in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Tacit programming means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Tacit programming out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Tacit programming in simple terms?

Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments (or "points") on which they operate. Instead the definitions merely compose other functions, among which are combinators that manipulate the arguments.

Why does Tacit programming matter?

Because it connects several science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Tacit programming?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Tacit programming.

Tags

  • Programming language comparisons
  • Programming paradigms

Keep exploring