Concatenative programming language explained

A concatenative programming language is a point-free computer programming language in which all expressions denote functions, and the juxtaposition of expressions denotes function composition.[1] Concatenative programming replaces function application, which is common in other programming styles, with function composition as the default way to build subroutines.

Example

For example, a sequence of operations in an applicative language like the following:

y = foo(x)z = bar(y)w = baz(z)

...is written in a concatenative language as a sequence of functions:[2]

x foo bar baz

Functions and procedures written in concatenative style are not value level, i.e. they typically do not represent the data structures they operate on with explicit names or identifiers. Instead they are function levela function is defined as a pipeline, or a sequence of operations that take parameters from an implicit data structure upon which all functions operate, and return the function results to that shared structure so that it will be used by the next operator.[3]

The combination of compositional semantics with a syntax that mirrors such a semantic makes concatenative languages highly amenable to algebraic manipulation of programs;[4] although it may be difficult to write mathematical expressions directly in them. Concatenative languages can be implemented efficiently with a stack machine, and are commonly present implicitly in virtual machines in the form of their instruction sets.[5]

Properties

The properties of concatenative languages are the result of their compositional syntax and semantics:

Implementations

The first concatenative programming language was Forth, although Joy was the first language to call itself concatenative. Other concatenative languages are dc, Factor, Onyx, PostScript, and RPL.

Most existing concatenative languages are stack-based; this is not a requirement and other models have been proposed.[9] [10] [11] Concatenative languages are currently used for embedded, desktop, and web programming, as target languages, and for research purposes.

Most concatenative languages are dynamically typed. Exceptions include the statically typed Cat language.[12]

See also

External links

Notes and References

  1. Web site: Christopher Diggins: What is a concatenative language . Drdobbs.com . 2008-12-31 . 2013-07-01.
  2. Web site: Name code not values . Concatenative.org . 13 September 2013.
  3. Web site: Concatenative language . Concatenative.org . 13 September 2013.
  4. Web site: Rationale for Joy, a functional language. https://web.archive.org/web/20110115151536/http://www.latrobe.edu.au/philosophy/phimvt/joy/j00rat.html. 2011-01-15.
  5. Web site: Why Concatenative Programming Matters . 13 September 2013.
  6. Web site: von Thun, Manfred: Joy compared with other functional languages . https://web.archive.org/web/20111006225512/http://www.latrobe.edu.au/phimvt/joy/j08cnt.html . 2011-10-06.
  7. Web site: von Thun, Manfred: Mathematical foundations of Joy . https://web.archive.org/web/20100731060810/http://www.latrobe.edu.au/philosophy/phimvt/joy/j02maf.html . 2010-07-31.
  8. Web site: Henry Baker: Linear Logic and Permutation Stacks — The Forth Shall Be First . Home.pipeline.com . 2013-07-01 . https://web.archive.org/web/20140724091729/http://home.pipeline.com/~hbaker1/ForthStack.html . 2014-07-24 . dead .
  9. Web site: The Concatenative Language XY . Nsl.com . 2013-07-01.
  10. Web site: The Enchilada Programming Language . Enchiladacode.nl . 2013-07-01.
  11. Web site: The Om Programming Language . Om-language.org . 2013-07-01.
  12. Web site: Cat Specification . Cat-language.com . 2013-07-01 . https://web.archive.org/web/20150205081218/http://cat-language.com/manual.html . 2015-02-05.