Concatenative programming language

Last updated

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.



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

y=foo(x)z=bar(y)w=baz(z) written in a concatenative language as a sequence of functions, without parameters: [2]

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, 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 a compositional semantics with a syntax that mirrors such a semantics 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 in an efficient way with a stack machine, and are commonly present implicitly in virtual machines in the form of their instruction sets. [5]

Much of the original work on concatenative language theory was carried out by Manfred von Thun.[ citation needed ]


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


The first concatenative programming language was Forth, although Joy was the first language to call itself concatenative. Other concatenative languages are 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

Related Research Articles

Forth is an imperative stack-based computer programming language and environment originally designed by Charles "Chuck" Moore. Language features include structured programming, reflection, concatenative programming and extensibility. Although not an acronym, the language's name is sometimes spelled with all capital letters as FORTH, following the customary usage during its earlier years.

Lisp (programming language) Programming language

Lisp is a family of computer programming languages with a long history and a distinctive, fully parenthesized prefix notation. Originally specified in 1958, Lisp is the second-oldest high-level programming language in widespread use today. Only Fortran is older, by one year. Lisp has changed since its early days, and many dialects have existed over its history. Today, the best-known general-purpose Lisp dialects are Clojure, Common Lisp, and Scheme.

In computer science, denotational semantics is an approach of formalizing the meanings of programming languages by constructing mathematical objects that describe the meanings of expressions from the languages. Other approaches provide formal semantics of programming languages including axiomatic semantics and operational semantics.

In programming languages, a closure, also lexical closure or function closure, is a technique for implementing lexically scoped name binding in a language with first-class functions. Operationally, a closure is a record storing a function together with an environment. The environment is a mapping associating each free variable of the function with the value or reference to which the name was bound when the closure was created. Unlike a plain function, a closure allows the function to access those captured variables through the closure's copies of their values or references, even when the function is invoked outside their scope.

In computer science, a compiler-compiler or compiler generator is a programming tool that creates a parser, interpreter, or compiler from some form of formal description of a programming language and machine.

In computer science, extended Backus–Naur form (EBNF) is a family of metasyntax notations, any of which can be used to express a context-free grammar. EBNF is used to make a formal description of a formal language such as a computer programming language. They are extensions of the basic Backus–Naur form (BNF) metasyntax notation.

A string literal or anonymous string is a type of literal in programming for the representation of a string value within the source code of a computer program. Most often in modern languages this is a quoted sequence of characters, as in x = "foo", where "foo" is a string literal with value foo – the quotes are not part of the value, and one must use a method such as escape sequences to avoid the problem of delimiter collision and allow the delimiters themselves to be embedded in a string. However, there are numerous alternate notations for specifying string literals, particularly more complicated cases, and the exact notation depends on the individual programming language in question. Nevertheless, there are some general guidelines that most modern programming languages follow.

Conditional (computer programming) programming language construct that performs actions according to boolean conditions

In computer science, conditional statements, conditional expressions and conditional constructs are features of a programming language, which perform different computations or actions depending on whether a programmer-specified boolean condition evaluates to true or false. Apart from the case of branch predication, this is always achieved by selectively altering the control flow based on some condition.

In computer programming, ?: is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages. It is commonly referred to as the conditional operator, inline if (iif), or ternary if. An expression a? b : c evaluates to b if the value of a is true, and otherwise to c. One can read it aloud as "if a then b otherwise c".

The Joy programming language in computer science is a purely functional programming language that was produced by Manfred von Thun of La Trobe University in Melbourne, Australia. Joy is based on composition of functions rather than lambda calculus. It has turned out to have many similarities to Forth, due not to design but to a sort of parallel evolution and convergence. It was also inspired by the function-level programming style of John Backus's FP.

Programming languages typically support a set of operators: constructs which behave generally like functions, but which differ syntactically or semantically from usual functions. Common simple examples include arithmetic, comparison, and logical operations. More involved examples include assignment, field access in a record or object, and the scope resolution operator. Languages usually define a set of built-in operators, and in some cases allow users to add new meanings to existing operators or even define completely new operators.

In computer science, a tail call is a subroutine call performed as the final action of a procedure. If a tail call might lead to the same subroutine being called again later in the call chain, the subroutine is said to be tail-recursive, which is a special case of recursion. Tail recursion is particularly useful, and often easy to handle in implementations.

In computer science, an abstract semantic graph (ASG) or term graph is a form of abstract syntax in which an expression of a formal or programming language is represented by a graph whose vertices are the expression's subterms. An ASG is at a higher level of abstraction than an abstract syntax tree, which is used to express the syntactic structure of an expression or program.

Syntax (programming languages) in programming languages

In computer science, the syntax of a computer language is the set of rules that defines the combinations of symbols that are considered to be a correctly structured document or fragment in that language. This applies both to programming languages, where the document represents source code, and to markup languages, where the document represents data.

Scala (programming language) programming language

Scala is a general-purpose programming language providing support for functional programming and a strong static type system. Designed to be concise, many of Scala's design decisions aimed to address criticisms of Java.

The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program.

Tacit programming, also called point-free style, is a programming paradigm in which function definitions do not identify the arguments 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 certain 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 unnecessarily obscure, hence the epithet "pointless style".

The syntax of the Python programming language is the set of rules that defines how a Python program will be written and interpreted. The Python language has many similarities to Perl, C, and Java. However, there are some definite differences between the languages.

A lightweight programming language is one that is designed to have very small memory footprint, is easy to implement, and/or has minimalist syntax and features.

Clojure A modern, dynamic, and functional Lisp on JVM

Clojure is a modern, dynamic, and functional dialect of the Lisp programming language on the Java platform. Like other Lisps, Clojure treats code as data and has a Lisp macro system. The current development process is community-driven, overseen by Rich Hickey as its benevolent dictator for life (BDFL).


  1. "Christopher Diggins: What is a concatenative language". 2008-12-31. Retrieved 2013-07-01.
  2. "Name code not values". Retrieved 13 September 2013.
  3. "Concatenative language". Retrieved 13 September 2013.
  4. "Rationale for Joy, a functional language". Archived from the original on 2011-01-15.
  5. 1 2 "Why Concatenative Programming Matters" . Retrieved 13 September 2013.
  6. "von Thun, Manfred: Joy compared with other functional languages". Archived from the original on 2011-10-06.
  7. "von Thun, Manfred: Mathematical foundations of Joy". Archived from the original on 2010-07-31.
  8. "Henry Baker: Linear Logic and Permutation Stacks — The Forth Shall Be First". Retrieved 2013-07-01.
  9. "The Concatenative Language XY". Retrieved 2013-07-01.
  10. "The Enchilada Programming Language". Retrieved 2013-07-01.
  11. "The Om Programming Language". Retrieved 2013-07-01.
  12. "Cat Specification". Archived from the original on 2015-02-05. Retrieved 2013-07-01.