Concatenative programming language: Difference between revisions

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
imported>Cubiccated
→Implementations: Added the Kitten programming language after Cat, since Cat seems to be dead while Kitten is still somewhat active.
 
imported>BunnysBot
 
Line 1: Line 1:
{{short description|Type of programming language}}
{{Short description|Type of programming language}}
<!-- {{bare URLs|date=June 2013}} -->


A '''concatenative programming language''' is a [[Point-free programming|point-free]] computer [[programming language]] in which all expressions denote [[Function (mathematics)|functions]], and the [[juxtaposition]] of [[Expression (computer science)|expressions]] denotes [[function composition]].<ref name="dobbscodetalk">{{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}}</ref> Concatenative programming replaces [[function application]], which is common in other programming styles, with [[function composition (computer science)|function composition]] as the default way to build [[subroutine]]s.
A '''concatenative programming language''' is a [[Point-free programming|point-free]] computer [[programming language]] in which all expressions denote [[Function (mathematics)|functions]], and the [[juxtaposition]] of [[Expression (computer science)|expressions]] denotes [[function composition]].<ref name="dobbscodetalk">{{cite magazine |last1=Diggins |first1=Christopher |date=2008-12-31 |url=http://drdobbs.com/blogs/architecture-and-design/228701299 |title=What is a concatenative language |magazine=[[Dr. Dobb's Journal]] |access-date=2013-07-01}}</ref> Concatenative programming replaces [[function application]], which is common in other [[programming paradigm]]s, with [[Function composition (computer science)|function composition]] as the default way to build [[Function (computer programming)|subroutines]].


==Example==
==Example==
Line 11: Line 10:
</syntaxhighlight>
</syntaxhighlight>


...is written in a concatenative language as a sequence of functions:<ref>{{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}}</ref>
...is written in a concatenative language as a sequence of functions:<ref>{{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}}</ref>


  x foo bar baz
  x foo bar baz


Functions and procedures written in concatenative style are not [[Value-level programming|value level]], i.e. they typically do not represent the data structures they operate on with explicit names or [[identifier#In computer science|identifiers]]. Instead they are [[Function-level programming|function level]]{{Spaced en dash}}a function is defined as a [[pipeline (software)|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.<ref>{{cite web | url=http://concatenative.org/wiki/view/Concatenative%20language | title=Concatenative language | publisher=Concatenative.org | access-date=13 September 2013}}</ref>
Functions and procedures written in concatenative style are not [[Value-level programming|value level]], i.e., they typically do not represent the data structures they operate on with explicit names or [[Identifier#In computer science|identifiers]]. Instead they are [[Function-level programming|function level]] – a function is defined as a [[pipeline (software)|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.<ref>{{cite web |url=http://concatenative.org/wiki/view/Concatenative%20language |title=Concatenative language |publisher=Concatenative.org |access-date=13 September 2013}}</ref>


The combination of compositional [[Semantics of programming languages|semantics]] with a [[Syntax of programming languages|syntax]] that mirrors such a semantic makes concatenative languages highly amenable to algebraic manipulation of programs;<ref>{{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}}</ref> although it may be difficult to write mathematical expressions directly in them.<ref name="whymatters"/> Concatenative languages can be implemented efficiently with a [[stack machine]], and are commonly present implicitly in [[virtual machine]]s in the form of their [[instruction set]]s.<ref name="whymatters">{{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}}</ref>
The combination of compositional [[Semantics (computer science)|semantics]] with a [[Syntax (programming languages)|syntax]] that mirrors such a semantic makes concatenative languages highly amenable to algebraic manipulation of programs;<ref>{{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}}</ref> although it may be difficult to write mathematical expressions directly in them.<ref name="whymatters"/> Concatenative languages can be implemented efficiently with a [[stack machine]], and are commonly present implicitly in [[virtual machine]]s in the form of their [[instruction set]]s.<ref name="whymatters">{{cite web |last1=Purdy |first1=Jon |date=12 February 2012 |url=http://evincarofautumn.blogspot.com/2012/02/why-concatenative-programming-matters.html |title=Why Concatenative Programming Matters |website=The Big Mud Puddle |access-date=12 August 2025}}</ref>


==Properties==
==Properties==
The properties of concatenative languages are the result of their compositional syntax and semantics:
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.<ref>{{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}}</ref>
* 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.<ref>{{cite web |last1=von Thun |first1=Manfred |year=2011 |url=http://www.latrobe.edu.au/phimvt/joy/j08cnt.html |title=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}}</ref>
* Any subexpression can be replaced with a name that represents the same subexpression. This is referred to in the concatenative community as [[Code refactoring|factoring]] and is used extensively to simplify programs into smaller parts.
* Any subexpression can be replaced with a name that represents the same subexpression. In concatenative programming practice, this is called [[Code refactoring|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]].<ref>{{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}}</ref>
* The syntax and semantics of concatenative languages form the algebraic structure of a [[monoid]].<ref>{{cite web |last1=von Thun |first1=Manfred |year=2009 |url=http://www.latrobe.edu.au/philosophy/phimvt/joy/j02maf.html |title=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}}</ref>
* Concatenative languages can be made well-suited to an implementation inspired by [[linear logic]] where no [[Garbage (computer science)|garbage]] is ever generated.<ref>{{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 }}</ref>
* Concatenative languages can be made well-suited to an implementation inspired by [[linear logic]] where no [[Garbage (computer science)|garbage]] is ever generated.<ref>{{cite report |last1=Baker |first1=Henry |year=1993 |url=http://home.pipeline.com/~hbaker1/ForthStack.html |title=Linear Logic and Permutation Stacks: The Forth Shall Be First |publisher=Nimble Computer Corporation |via=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}}</ref>


==Implementations==
==Implementations==
The first concatenative programming language was [[Forth (programming language)|Forth]], although [[Joy (programming language)|Joy]] was the first language to call itself concatenative. Other concatenative languages are [[Dc_(computer_program)|dc]], [[Factor (programming language)|Factor]], Onyx, [[PostScript]], and [[RPL (programming language)|RPL]].
The first concatenative programming language was [[Forth (programming language)|Forth]], although [[Joy (programming language)|Joy]] was the first language which was termed concatenative. Other concatenative languages are [[dc (computer program)|dc]], [[Factor (programming language)|Factor]], Onyx, [[PostScript]], [[RPL (programming language)|RPL]], Staapl,<ref name="Staapl">{{cite web |last1=Schouten |first1=Tom (zwizwa) |date=<!-- Undated --> |url=http://zwizwa.be/staapl/ |title=Staapl: Forth on Scheme for Embedded Controllers |website=Zwizwa LLC |access-date=12 August 2025}}</ref> and experimental and discontinued ones including:<!-- Alphabetic order--> Enchilada,<ref name="Enchilada">{{cite web |author1=rapido |author2=NewDave |author3=jacintheford |author4=goren |date=2 January 2024 |url=https://concatenative.org/wiki/view/Enchilada |title=Enchilada |website=Concatenative.org |access-date=12 August 2025}}</ref> Om,<ref name="Om">{{cite web |author1=sparist |date=<!-- Undated --> |url=https://www.om-language.com/ |title=The Om Programming Language |website=Om-language.com |access-date=12 August 2025}}</ref> XY.<ref name="XY">{{cite web |last1=Apter |first1=Stevan |date=2004 |url=http://www.nsl.com/k/xy/xy.htm |title=The Concatenative Language XY |website=no stinking loops |access-date=12 August 2025}}</ref>


Most existing concatenative languages are [[stack-based]]; this is not a requirement and other models have been proposed.<ref>{{cite web|url=http://www.nsl.com/k/xy/xy.htm |title=The Concatenative Language XY |publisher=Nsl.com |access-date=2013-07-01}}</ref><ref>{{cite web|url=http://www.enchiladacode.nl/ |title=The Enchilada Programming Language |publisher=Enchiladacode.nl |access-date=2013-07-01}}</ref><ref>{{cite web|url=http://www.om-language.org/ |title=The Om Programming Language |publisher=Om-language.org |access-date=2013-07-01}}</ref> Concatenative languages are currently used for [[embedded systems|embedded]], [[Application software|desktop]], and [[web programming]], as [[Target language (computing)|target languages]], and for research purposes.
Most existing concatenative languages are [[Stack-oriented programming|stack-based]]. This is not required, and other models have been proposed.<ref name="XY"/><ref name="Enchilada"/><ref name="Om"/> Concatenative languages are currently used for [[Embedded system|embedded]],<ref name="Staapl"/> [[Application software|desktop]], and [[Web development|web programming]], as [[Translator (computing)|target languages]], and for research purposes.


Most concatenative languages are [[dynamically typed]]. Exceptions include the [[statically typed]] Cat language<ref>{{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}}</ref> and its successor, Kitten<ref>{{Cite web |title=Kitten Programming Language |url=https://kittenlang.org/ |access-date=2025-03-31 |website=kittenlang.org}}</ref>.
Most concatenative languages are [[dynamically typed]]. Exceptions include the [[statically typed]] Cat language<ref>{{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}}</ref> and its successor, Kitten.<ref>{{Cite web |last1=Purdy |first1=Jon |title=Kitten Programming Language |url=https://kittenlang.org/ |access-date=2025-03-31 |website=kittenlang.org}}</ref>


==See also==
==See also==
Line 44: Line 43:


==External links==
==External links==
* [http://www.concatenative.org concatenative.org: A wiki about concatenative languages]
* [http://www.concatenative.org/ Concatenative.org: Wiki], about concatenative programming
* [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}}
{{Programming paradigms navbox}}
Line 55: Line 50:
{{DEFAULTSORT:Concatenative Programming Language}}
{{DEFAULTSORT:Concatenative Programming Language}}
[[Category:Concatenative programming languages| ]]
[[Category:Concatenative programming languages| ]]
<!-- Hidden categories below -->
[[Category:Articles with example JavaScript code]]

Latest revision as of 15:03, 15 November 2025

Template:Short description

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

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:[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

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.[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

The 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

References

<templatestyles src="Reflist/styles.css" />

  1. ↑ Script error: No such module "Citation/CS1".
  2. ↑ Script error: No such module "citation/CS1".
  3. ↑ Script error: No such module "citation/CS1".
  4. ↑ Script error: No such module "citation/CS1".
  5. ↑ a b Script error: No such module "citation/CS1".
  6. ↑ Script error: No such module "citation/CS1".
  7. ↑ Script error: No such module "citation/CS1".
  8. ↑ Script error: No such module "citation/CS1".
  9. ↑ a b Script error: No such module "citation/CS1".
  10. ↑ a b Script error: No such module "citation/CS1".
  11. ↑ a b Script error: No such module "citation/CS1".
  12. ↑ a b Script error: No such module "citation/CS1".
  13. ↑ Script error: No such module "citation/CS1".
  14. ↑ Script error: No such module "citation/CS1".

Script error: No such module "Check for unknown parameters".

External links

Template:Programming paradigms navbox Script error: No such module "Navbox".