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 paradigms, with function composition as the default way to build subroutines.
Example
editFor 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:[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 level – a function is defined as a pipeline, or a sequence of operations that take parameters from an implicit data structure on 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.[5] 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
editThe 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.[6]
- Any subexpression can be replaced with a name that represents the same subexpression. In concatenative programming practice, this is called 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.[7]
- Concatenative languages can be made well-suited to an implementation inspired by linear logic where no garbage is ever generated.[8]
Implementations
editThe first concatenative programming language was Forth, although Joy was the first language which was termed concatenative. Other concatenative languages are dc, Factor, Onyx, PostScript, RPL, Staapl,[9] and experimental and discontinued ones including: Enchilada,[10] Om,[11] XY.[12]
Most existing concatenative languages are stack-based. This is not required, and other models have been proposed.[12][10][11] Concatenative languages are currently used for embedded,[9] desktop, and web programming, as target languages, and for research purposes.
Most concatenative languages are dynamically typed. Exceptions include the statically typed Cat language[13] and its successor, Kitten[14].
See also
editReferences
edit- ^ Diggins, Christopher (2008-12-31). "What is a concatenative language". Dr. Dobb's Journal. Retrieved 2013-07-01.
- ^ "Name code not values". Concatenative.org. Retrieved 13 September 2013.
- ^ "Concatenative language". Concatenative.org. Retrieved 13 September 2013.
- ^ "Rationale for Joy, a functional language". Archived from the original on 2011-01-15.
- ^ a b Purdy, Jon (12 February 2012). "Why Concatenative Programming Matters". The Big Mud Puddle. Retrieved 12 August 2025.
- ^ von Thun, Manfred (2011). "Joy compared with other functional languages". Archived from the original on 2011-10-06.
- ^ von Thun, Manfred (2009). "Mathematical foundations of Joy". Archived from the original on 2010-07-31.
- ^ Baker, Henry (1993). Linear Logic and Permutation Stacks: The Forth Shall Be First (Report). Nimble Computer Corporation. Archived from the original on 2014-07-24. Retrieved 2013-07-01 – via Home.pipeline.com.
- ^ a b Schouten, Tom (zwizwa). "Staapl: Forth on Scheme for Embedded Controllers". Zwizwa LLC. Retrieved 12 August 2025.
- ^ a b rapido; NewDave; jacintheford; goren (2 January 2024). "Enchilada". Concatenative.org. Retrieved 12 August 2025.
- ^ a b sparist. "The Om Programming Language". Om-language.com. Retrieved 12 August 2025.
- ^ a b Apter, Stevan (2004). "The Concatenative Language XY". no stinking loops. Retrieved 12 August 2025.
- ^ "Cat Specification". Cat-language.com. Archived from the original on 2015-02-05. Retrieved 2013-07-01.
- ^ Purdy, Jon. "Kitten Programming Language". kittenlang.org. Retrieved 2025-03-31.
External links
edit- Concatenative.org: Wiki, about concatenative programming