The Artima Developer Community
Sponsored Link

Weblogs Forum
Version 0.3 of the Cat Programming Language

6 replies on 1 page. Most recent reply: Jul 4, 2006 4:30 PM by Christopher Diggins

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 6 replies on 1 page
Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Version 0.3 of the Cat Programming Language (View in Weblogs)
Posted: Jun 30, 2006 7:22 PM
Reply to this message Reply
Summary
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.
Advertisement
This is a note to let everyone know that the latest and greatest version of Cat is now online at http://www.cdiggins.com/cat/cat.zip.

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
echo

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

// executing the function
i 
echo

// swapping values
1 2 swap echo

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

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

// using the new command
1 2 3 popall
echo

// 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.


Jonathan Finn

Posts: 10
Nickname: lucretius
Registered: Jun, 2006

Re: Version 0.3 of the Cat Programming Language Posted: Jun 30, 2006 7:43 PM
Reply to this message Reply
> Cat is a stack-based language, like Forth and Joy, which
> is very efficient and has an extremely small footprint.


Pawprint, surely?

Jules Jacobs

Posts: 119
Nickname: jules2
Registered: Mar, 2006

Re: Version 0.3 of the Cat Programming Language Posted: Jul 2, 2006 2:39 PM
Reply to this message Reply
This looks good!

The optimization happens in C# now, do you think that it's possible to move it to Cat?

If you have a hashtable of functions, you could make this hashtable accessible at runtime. This way you can modify this table before the actual program runs, and you could distribute optimizations as a Cat library.

As an abstraction of def and a function that reads definitions from the table you could provide optimize:

[1 +] [dec] optimize

Bill Tozier

Posts: 1
Nickname: btozier
Registered: Jul, 2006

Re: Version 0.3 of the Cat Programming Language Posted: Jul 4, 2006 7:55 AM
Reply to this message Reply
I'm just curious: are you familiar with Lee Spector and Maarten Keijzer's Push language? (see http://hampshire.edu/lspector/push3-description.html) If you were to add strong typing to Cat, you'd be very close to re-creating it. It was originally created for evolutionary programming applications, and is quite powerful for those. But the code (in that case) is not meant to be read or written by people.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: Version 0.3 of the Cat Programming Language Posted: Jul 4, 2006 1:04 PM
Reply to this message Reply
> This looks good!
>
> The optimization happens in C# now, do you think that it's
> possible to move it to Cat?

Yes, it will eventually all move back to Cat.

> If you have a hashtable of functions, you could make this
> hashtable accessible at runtime. This way you can modify
> this table before the actual program runs, and you could
> distribute optimizations as a Cat library.
>
> As an abstraction of def and a function that reads
> definitions from the table you could provide optimize:
>
> [1 +] [dec] optimize

I do agree with the sentiment that optimization should be accessible from the language run-time.

I'd write it like this:

$my_function [[1 +] dec] optimize def

Optimize would take an anonymous function and optimize it.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: Version 0.3 of the Cat Programming Language Posted: Jul 4, 2006 1:10 PM
Reply to this message Reply
> I'm just curious: are you familiar with Lee Spector and
> Maarten Keijzer's Push language? (see
> http://hampshire.edu/lspector/push3-description.html) If
> f you were to add strong typing to Cat, you'd be very
> close to re-creating it. It was originally created for
> evolutionary programming applications, and is quite
> powerful for those. But the code (in that case) is not
> meant to be read or written by people.

Thanks for pointing that out. I do see some similarities between the Push language and the Cat language.

Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

Re: Version 0.3 of the Cat Programming Language Posted: Jul 4, 2006 4:30 PM
Reply to this message Reply
> > Cat is a stack-based language, like Forth and Joy,
> which
> > is very efficient and has an extremely small footprint.
>
>
>
> Pawprint, surely?

Agreed, pawprint is definitely more approrpriate. :-)

Flat View: This topic has 6 replies on 1 page
Topic: Version 0.3 of the Cat Programming Language Previous Topic   Next Topic Topic: Resisting the Pull of Language Evolution


Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us