Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.

Channels ▼


Cat: A Functional Stack-Based Little Language

Source Code Accompanies This Article. Download It Now.

Cat Implementation

I have released several Cat interpreters as public domain code, which you can use and modify as you wish. The primary implementation of Cat is an open-source C# interpreter (www.cat-language.com) that performs type checking, type inference, and some basic optimization (function inlining and partial evaluation). It also has several extensions such as named parameters and MetaCat rewriting rules. The Cat language website provides an embedding of Cat in Scheme and an online Cat interpreter written in JavaScript. The JavaScript and Scheme implementations are a bit out of sync with the language specification and are intended only as demonstrations, but feel free to redistribute and/or modify them. I have also written a basic Scheme-to-Cat translator, in Scheme.


Cat has potential applications in many domains. I can envision a place for it in embedded devices due to its compact and expressive nature. I also believe that Cat would be useful in a computer-science curriculum as a tool for explaining the rudiments of computer programs. The immediate feedback you get viewing the stack after each instruction can be useful for instruction. My intentions are to use Cat as an intermediate language for translation and optimization for my other computer language projects, and as a language for teaching programming.

If you are interested stack languages and aren't familiar with Forth, a fun primer is a fully documented bootstrapping compiler by Richard W.M. Jones (www.annexia.org/forth). I also recommend Manfred von Thun's writings on Joy, even if you never plan on using stack languages. Some up-and-coming stack languages are Factor (www.factorcode.org) by Slava Pestov and Ripple (ripple.fortytwo.net) by Joshua Shinavier, a stack language designed for the Semantic Web.


Thanks to the members of the concatenative mailing list (tech.groups.yahoo.com/group/concatenative), the Cat mailing list (groups.google.com/group/catlanguage), and the Lambda-the-Ultimate.org programming language blog. In particular, I want to thank William Tanksley, Joshua Shinavier, Frank Krueger, and John Nowak.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.