Joy and Concatenative Programming
S. Alexander Jacobson
Tue, 25 Sep 2001 02:08:48 -0400 (Eastern Daylight Time)
I just found out about a functional programming language called Joy (see
Joy differs from Haskell in that it has no variables. Instead, all
functions are postfix, taking a stack as their argument and returning a
stack as a result.
Joy advocates contend that the elimination of variables and environments
improves on functional languages in much the same way the elimination of
state improved on imperative languages. In particular, they claim the
result is massively simplified semantics and implementation (all the
tree-rewriting rules go away), faster development, easier optimization
(search and replace lists of functions) and even simple meta-programming.
Here is a quick example program to give a flavor for how it works.
[1 2 3 4] [dup *] map == [1 2 3 4] [square] map
is the same as Haskell's
map (\x->x*x) [1,2,3,4] == map square [1,2,3,4]
Recursion is handled via some built in combinator primitives. For example
this is qsort:
qsort == [small]  [uncons [>] split] [[swap] dip cons concat] binrec
(the explanation of how this works is at
Currently Joy is a interpreted language without a compiler checked
type-system, but there is some discussion about adding such a system.
(It is also apparently non-lazy, but I'm not sure what that means in a
world without variables).
The system is very new and primitive, but looks promising. I am curious
what the wiser and more experienced people on this list think of Joy's
S. Alexander Jacobson Shop.Com
1-646-638-2300 voice The Easiest Way To Shop (sm)