Joy and Concatenative Programming
Tue, 25 Sep 2001 14:22:44 +0200
[redirected to haskell-cafe]
> 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.
Also, IIRC, Joy is untyped.
Programming in Joy is like programming with categorical combinators, but
ignoring the types. Indeed, a category with one object is just a monoid, and
this is supposedly the theory Joy is founded on.
But if you really think variables are a nuisance to programming, you can do
it in Haskell too, by using list combinators and defining a reverse
composition operator. Or just go program in CAML bytecode. It's pretty much
the same thing.
> 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.
I think the situations are qualitatively different.
Saying that Joy programs "lack variables" is pretty close to saying that its
free variable environments are linearly ordered. Yet a Joy programmer can
reorder the arguments on the stack if he rewrites his program to take
account of that fact. So, though the ordering is really irrelevant, every
Joy program must pick one, and that can be understood as non-declarative,
since it has nothing to do with the result of the program. FP languages
factor out that arbitrary choice by treating free variable environments as
(multi-)sets. (Of course, you lose that advantage when you package up your
environment in a closure, because Haskell distinguishes between a -> b -> c
and b -> a -> c, even though they are isomorphic.)
Frank Atanassow, Information & Computing Sciences, Utrecht University
Padualaan 14, PO Box 80.089, 3508TB Utrecht, The Netherlands
Tel +31 (0)30 253-3261 Fax +31 (0)30 251-3791