🐱Joy

Created by Manfred von Thun, Joy can be considered the "cannonical" catlang. It was the first language to be describe and analyses this way. However, it's evolution shares many parallels to Forth. Many of the properties found in Joy can be found in Forth. Thus, the two languages are often pared together.

Joy is a purely-functional language that introduced many of the Combinators used by later catlangs. It's core syntax included Quotations and word / function definitions.

fact == 1 1 rolldown [dup [*] dip succ] times pop
gcd  ==  [0 >] [dup [rem] dip swap] while pop

All control flow in Joy was defined in terms of Combinators. These are words which receive one or more quotations as inputs. Quotations can be thought of as anonymous functions, a list of instructions, or a string representing a sub-program.

Joy also features the ability to define libraries as well as private definitions.

LIBRA (* queue *)

HIDE
  error   == "non_empty queue needed for " putchars putchars newline abort;
  prepare == [null] [swap reverse] [] ifte
IN
  q-new   == [] [];
  q-add   == swap [swons] dip;
  q-addl  == swap [shunt] dip;
  q-null  == prepare dup null;
  q-front == prepare [null] ["q-front" error] [dup first] ifte;
  q-rem   == prepare [null] ["q-rem "  error] [unswons  ] ifte
END.

Unlike other catlangs, Joy's stack was implemented using an immutable tree. This allowed various control flow combinators in joy to act on the stack immutably. Later languages would opt out of this due to the performance overhead.