The Artima Developer Community
Sponsored Link

Weblogs Forum
A Brief Description of Cat

0 replies on 1 page.

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 0 replies on 1 page
Christopher Diggins

Posts: 1215
Nickname: cdiggins
Registered: Feb, 2004

A Brief Description of Cat (View in Weblogs)
Posted: Apr 24, 2007 2:13 AM
Reply to this message Reply
Summary
The Cat programming language version 0.11 has just been released. I thought I'd take a moment to talk a bit about what Cat is all about.
Advertisement
The Cat programming language has just released version 0.11.0 at Google code hosting. The interpreter is released under the MIT license (due to restrictions imposed by Google code hosting) while the source code for the interpreter is public domain C# code.

Cat as an Intermediate Language

My original motivation for designing Cat was as an intermediate programming language. I had studied the .NET Common Intermediate Language (CIL) and Java bytecode and I noticed a similarity between these languages and the functional programming language Joy. The big difference between Joy and most intermediate stack-based languages is the fact that instructions in Joy can all be pushed onto the stack as data. A trait also shared with the Postscript language.

More Compact/Expressive Code

Allowing instructions to be pushed onto the stack as data and executed is very powerful. You can express very complex algorithms using very few commands. For example a simple version of the Google MapReduce algorithm in just one-line of Cat code:
  define map_reduce { [map flatten self_join] dip map }

Improved Concurrency

One advantage of functional languages, is that they make it much easier to express algorithms without specifying superflous sequential dependencies. In other words it is easier to run functional code concurrently. For example if I want to express the algorithm for adding one to each element in a list, the assembly code usually specifies a sequence which is not neccessary. Using higher-order functions we can express the algorithm more accurately as:
  define add_one_to_all_items { [1 +] map } 
The map instruction can be easily implemented to take advantage of multi-core or multi-processor machines.

Type System

Joy lacks a type-system, so I designed the Cat language based on Joy but with type-checking in mind. This restricts some of the operations that are available, but improves the safety and verifiability of code. Admittedly the current Cat implementation lacks a type-checker but I have formally defined the Cat type system in a technical report. Having a type-system makes it possible for Cat code to be verified before execution thus improving security and enabling many optimizations. Types are also very useful as a form of documentation of stack effects, but are not mandatory since they can be inferred by the compiler.

Cat as a Teaching Language

The other role I envision for the Cat language is as a language for teaching programming. I used as my inspiration the fact that many people first learned programming using RPL on Hewlett Packard calculators. Stack-based languages have very simple semantics and are very easy to teach. A popular teaching language for kids is Logo, so I've added a logo-style graphics library to Cat (see http://cat-language.googlecode.com/svn/trunk/cat/graphics.cat ).

You can see a screen-shot of the graphics engine in action at http://cat-language.com/screen.png.

Topic: A Brief Description of Cat Previous Topic   Next Topic Topic: Open Source Python for Nokia S60

Sponsored Links



Google
  Web Artima.com   

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