Concatenative programming language
{{short description|Type of programming language}}
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.{{cite web|url=http://drdobbs.com/blogs/architecture-and-design/228701299 |title=Christopher Diggins: What is a concatenative language |publisher=Drdobbs.com |date=2008-12-31 |access-date=2013-07-01}} 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 nesting of operations in an applicative language like the following:
baz(bar(foo(x)))
...is written in a concatenative language as a sequence of functions:{{cite web | url=http://concatenative.org/wiki/view/Concatenative%20language/Name%20code%20not%20values | title=Name code not values | publisher=Concatenative.org | access-date=13 September 2013}}
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 level{{Spaced en dash}}a 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.{{cite web | url=http://concatenative.org/wiki/view/Concatenative%20language | title=Concatenative language | publisher=Concatenative.org | access-date=13 September 2013}}
The combination of compositional semantics with a syntax that mirrors such a semantic makes concatenative languages highly amenable to algebraic manipulation of programs;{{cite web|url=http://www.latrobe.edu.au/philosophy/phimvt/joy/j00rat.html|archive-url=https://web.archive.org/web/20110115151536/http://www.latrobe.edu.au/philosophy/phimvt/joy/j00rat.html|archive-date=2011-01-15|title=Rationale for Joy, a functional language}} 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.{{cite web | url=http://evincarofautumn.blogspot.com.es/2012/02/why-concatenative-programming-matters.html | title=Why Concatenative Programming Matters | access-date=13 September 2013}}
Properties
The properties of concatenative languages are the result of their compositional syntax and semantics:
- The reduction of any expression is the simplification of one function to another function; it is never necessary to deal with the application of functions to objects.{{cite web|url=http://www.latrobe.edu.au/phimvt/joy/j08cnt.html |title=von Thun, Manfred: Joy compared with other functional languages |archive-url=https://web.archive.org/web/20111006225512/http://www.latrobe.edu.au/phimvt/joy/j08cnt.html |archive-date=2011-10-06}}
- Any subexpression can be replaced with a name that represents the same subexpression. This is referred to in the concatenative community as factoring and is used extensively to simplify programs into smaller parts.
- The syntax and semantics of concatenative languages form the algebraic structure of a monoid.{{cite web|url=http://www.latrobe.edu.au/philosophy/phimvt/joy/j02maf.html |title=von Thun, Manfred: Mathematical foundations of Joy |archive-url=https://web.archive.org/web/20100731060810/http://www.latrobe.edu.au/philosophy/phimvt/joy/j02maf.html |archive-date=2010-07-31}}
- Concatenative languages can be made well-suited to an implementation inspired by linear logic where no garbage is ever generated.{{cite web |url=http://home.pipeline.com/~hbaker1/ForthStack.html |title=Henry Baker: Linear Logic and Permutation Stacks — The Forth Shall Be First |publisher=Home.pipeline.com |access-date=2013-07-01 |archive-url=https://web.archive.org/web/20140724091729/http://home.pipeline.com/~hbaker1/ForthStack.html |archive-date=2014-07-24 |url-status=dead }}
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.{{cite web|url=http://www.nsl.com/k/xy/xy.htm |title=The Concatenative Language XY |publisher=Nsl.com |access-date=2013-07-01}}{{cite web|url=http://www.enchiladacode.nl/ |title=The Enchilada Programming Language |publisher=Enchiladacode.nl |access-date=2013-07-01}}{{cite web|url=http://www.om-language.org/ |title=The Om Programming Language |publisher=Om-language.org |access-date=2013-07-01}} 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{{cite web|url=http://www.cat-language.com/manual.html |title=Cat Specification |publisher=Cat-language.com |access-date=2013-07-01 |archive-url=https://web.archive.org/web/20150205081218/http://cat-language.com/manual.html |archive-date=2015-02-05}} and its successor, Kitten{{Cite web |title=Kitten Programming Language |url=https://kittenlang.org/ |access-date=2025-03-31 |website=kittenlang.org}}.
See also
References
{{Reflist}}
External links
- [http://www.concatenative.org concatenative.org: A wiki about concatenative languages]
- [http://zwizwa.be/staapl Staapl: Forth on Scheme for Embedded Controllers]
- [http://www.enchiladacode.nl The Enchilada Programming Language]
- [http://www.nsl.com/k/xy/xy.htm The Concatenative Language XY]
- [http://om-language.org The Om Programming Language]
{{Programming paradigms navbox}}
{{Types of programming languages}}
{{DEFAULTSORT:Concatenative Programming Language}}