The Artima Developer Community
Sponsored Link

Heron-Centric: Ruminations of a Language Designer
Version 0.3 of the Cat Programming Language
by Christopher Diggins
June 30, 2006
I've just released a new version of Cat, and it is leaner and meaner than ever. There have been syntax changes, and I attempt to provide a brief but useful tutorial.


This is a note to let everyone know that the latest and greatest version of Cat is now online at

Cat is a stack-based language, like Forth and Joy, which is very efficient and has an extremely small footprint.

In Cat everything is a function which takes 0 or more parameters from a shared stack and returns 0 or more result values on the same shared stack. For example if you write the number 42 it will push an integer with the value 42 onto the stack. If you write + it will remove the top two elements from the stack, and push the sum of them.

Prefixing an identifier with a dollar-sign ($) will cause the identifier to be pushed as a token, rather than being executed. Quoting 1 or more functions with square brackets (e.g. [40 2 +]) will cause a function to be pushed onto the stack which represents the concatenation of those functions. This program can then be executed using the primitive function i, or passed to other functions which accept functions as parameters.

Here is an example of a Cat program:

// adding two numbers together
40 2 + echo

// removing a value from the stack
pop echo

// removing another value from the stack
pop echo

// looking at the top of an empty stack

// pushing a function onto the stack
[40 2 +]

// executing the function

// swapping values
1 2 swap echo

// clearing the whole stack
[pop] [stack_empty not] while

// creating a new command
$popall [[pop] [stack_empty not] while] def

// using the new command
1 2 3 popall

// branch logic
42 echo dup 10 > ["is greater than 10"] ["is less than 10"] if echo
The primary intended use for Cat is as a high-level intermediate form for other programming languages. The ultimate goal, albeit a quixotic one, is to come up with a language which can be used as a universal target for any other programming language, and which can be easily translated into any other language.

Talk Back!

Have an opinion? Readers have already posted 6 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Christopher Diggins adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Christopher Diggins is a software developer and freelance writer. Christopher loves programming, but is eternally frustrated by the shortcomings of modern programming languages. As would any reasonable person in his shoes, he decided to quit his day job to write his own ( ). Christopher is the co-author of the C++ Cookbook from O'Reilly. Christopher can be reached through his home page at

This weblog entry is Copyright © 2006 Christopher Diggins. All rights reserved.

Sponsored Links


Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use