• Concat is a language one can interactively work
with on the console; we regard interactivity as es-
sential for an experimental approach to LDSD and
LOP
• Concat is homoiconic, i.e. code can be treated as
data and data as code
• Concat has a very simple syntax. Programs are
created by concatenating words and so-called
quotations, and there are just three tokens with
special meaning: whitespace,
[
and
]
• Similarily, Concat has very simple semantics. We
distinguish the level of words and quotations from
the level of functions processing stacks
• Both levels of Concat maintain a relationship
called a homomorphism; that means that there is
a structure preserving mapping from the syntactic
level of words and quotations to the semantic level
of functions and stacks
There are immediate implications that followfrom
these characteristics: (1) Concat has a sound mathe-
matical foundation, which enables formal treatment
and reasoning over programs. (2) There are no vari-
able bindings in Concat, that means there are no struc-
tural ties beyond the homomorphism mentioned. And
that has two other important consequences especially
for code engineering: (3) Concat supports macros out
of the box without further ado. (4) One can cut out
any fragment of code at whitespaces. Presumed that
you leave the code within squared brackets intact, any
such fragment still represents a valid program. This is
something, which is impossible in, say, Java, C#, Lisp
or Haskell. Concat enables code reuse and refactoring
of code to an extent unknown in other languages.
We think that Concat offers many interesting
properties. We formally define Concat in Sec. 3 after
we have briefly touched upon related work in Sec. 2.
We hold the view that concatenative languages de-
serve much more attention than is the case. They are
inspiring, usable and practical despite and because of
their simplicity, see Sec. 4 – a position surely debat-
able. We draw some conclusions in Sec. 5.
2 RELATED WORK
Much of the foundational work on concatenative lan-
guages wasdone by Manfred von Thun in conjunction
with the development of the Joy language.
1
Today,
several implementations of concatenative languages
exist. Cat is a purely functional language that unlike
1
http://www.latrobe.edu.au/philosophy/phimvt
Joy and like Concat supports static type checking.
2
Factor is a programming language designed for use
in practice. It has a concatenative core and supports
object-oriented programming.
3
Concatenative languages are closely related to
stack-based languages.
4
The former are characterized
by the homomorphic relationship between words/
quotations and functions, the latter by the use of a
stack as the central concept in the execution model.
A language may be both stack-based and concatena-
tive, but this must not necessarily be the case. Forth
(Rather et al., 1996) and PostScript (Adobe Systems
Inc., 1999) are popular “high-level” stack-based lan-
guages that are not concatenative. Several assem-
bly and intermediate languages also use a stack-based
model of execution.
In a concatenative language, even those words
that may intuitively be perceived as data, for exam-
ple numbers and strings, denote functions. Thus, con-
catenative languages are not only functional in the
sense that functions have no side effects, but also in
the sense that “everything is a function”. This form of
purity and the non-existence of variables relates them
closely to function-level programming as defined in
(Backus, 1978) and the point-free style of functional
programming (Gibbons, 1999).
3 FORMAL FOUNDATIONS
In this section we will define the concatenative lan-
guage Concat. Due to space limitations we restrict our
presentation to a dynamically typed version of Con-
cat. Actually, Concat is statically typed enabling the
programmer to define arbitrary types as encodings.
A specialty of concatenative languages is that
there is the level of words and quotations (Sec. 3.1
and 3.2) and the level of functions and stacks (Sec. 3.3
and 3.4). Both levels have their own concepts and
their own semantics. However, the levels are con-
structed in such a way that there is a close relationship
between the two (Sec. 3.5).
3.1 Words and Quotations
On the syntactic level, Concat is defined by only
some few concepts: vocabularies of words, quota-
tions, stack pools, programs, concatenation and sub-
stitution.
2
http://www.cat-language.com
3
http://factorcode.org
4
http://concatenative.org
ICSOFT 2009 - 4th International Conference on Software and Data Technologies
258