cdiggins.com

March 20, 2007

Abstract Data Type Analysis

Filed under: Everything — cdiggins @ 5:09 pm

I am interested in possibly performing a program analysis in Cat at compile time which would allow the implementation of an abstract data type (ADT) to be made by the compiler based on the operations chosen. For example if an instance of a collection ADT only uses “at” operations then it might be best implemented as an array, but if it uses “insert” operations then it might be a better candidate for a linked list.

It seems that letting the compiler choose the data type implementation at compile-time should be a pretty straightforward thing to do, but I’d first like to find out more about the success of others using similar approaches in a programming langauge.

March 19, 2007

Abstraction Algorithm : From Named Parameters to Point Free Form

Filed under: Everything — cdiggins @ 4:44 pm

I haven’t encountered many people who really enjoy writing code in point-free form (e.g. no named parameters). This is one of the big criticisms of stack-based functional languages like Joy and Cat. However writing a variant of a stack-based functional langauge with named parameters is a relatively straightforward thing to do (see Theory of Concatenative Combinators by Brent Kerby for a naive algorithm). This approach involves rewriting the algorithm using combinators.

The approach I am considering is to package all arguments to a function in an associative list. This is a more high-level approach, and has several advantages. For example it makes it easier to map from dynamic languages that implement named parameters and argument reflection to Cat. Another advantage is that it is slightly easier to implement. The downside is that it has a potentially big performance hit, if implemented naively.

At this point I think it is smartest to go with a simple implementation.

March 18, 2007

Typing Functional Stack-Based Languages

Filed under: Everything — cdiggins @ 9:38 pm

I’ve rewritten the Cat technical report and made it into a more general purpose article: Typing Functional Stack-Based Languages.

 The abstract follows:

Stack-based languages have been in continuous use for approximately four decades, and are still very popular today as intermediate languages. Many of the most well-known stack-based languages (e.g. Forth, Postscript, CIL, JVML) lack support for functional programming at the primitive instruction level. Some notable exceptions are the Joy programming language by Manfred von Thun and the Factor programming language by Slava Pestov. There has also been a recent proposal to add lambda expressions to Forth by Lynas and Stoddart.

While functional stack-based languages are gaining popularity, none of these have a static type system. This paper addresses this gap by formally expressing the operational semantics and type system for Cat, a small functional stack-based language.

Any comments or suggestions would be greatly appreciated!

March 17, 2007

Visual Programming Languages: More than Just a Toy?

Filed under: Everything — cdiggins @ 5:07 pm

A visual programming language allows you to design a program by dragging and dropping visual components. They haven’t had a whole lot of success in general, but seem to be gaining traction as good tools for teaching programming to children.

A new one being developed at MIT seems to be gaining some traction as a children’s tool: Scratch.

I’ll have to look more carefully at it, but there is a small possibility that they may be inherently an order of magnitude more powerful than other text-based languages. If they are truly easy to learn for small children, then they may in fact be so powerful that the community at large may overlook the capabilities. This wouldn’t be the first time such a thing has happened. Logo is an example of a ridiculously powerful langauge, which was completely overlooked by many people, professionals and researchers alike.

New ideas or approaches that are fundamentally more powerful than existing ones are oftent dismissed prematurely as being toys and are assumed to be lacking any fundamental improvement in expressive power. Anyway, something to think about, the next time you want to dismiss a language by calling it a toy.

March 13, 2007

A Cat Variant with Named Parameters

Filed under: Everything — cdiggins @ 7:59 pm

A new variant of Cat I am working on provides support for optional named parameters. The conversion to plain Cat is very simple, but it makes code much more readable and manageable. I’m thinking of calling the variant “Tabby Cat”, but that is neither here nor there.

People Talking about Heron

Filed under: Everything — cdiggins @ 7:55 pm

People are talking about the Heron language on Lambda-the-Ultimate.org. Well not really, but the features many people describe in an OO language sound like Heron’s features. Heron supports structural subtyping and delegation. The next release of HeronFront will scale back some of the features, and emphasize its usage as a code generation tool for C++. If all goes according to plan I’ll be submitting an article on Heron to Doctor Dobbs in a couple of months.

March 9, 2007

What’s Next for Mr. Diggins?

Filed under: Everything — cdiggins @ 9:42 pm

Now that I have given my official notice that I’m leaving Microsoft, I have a lot of plans in the works. If all goes well I’ll be pursuing my Master’s degree in the Fall. Until then I plan on continuing work on the Cat programming language, releasing a new version of HeronFront, releasing a new version of the YARD parser, writing some articles about these projects for Dr. Dobbs Journal, and getting started on an introductory computer science textbook. Of course I’d be lucky to get even some of that finsished! :-)

Leaving Microsoft

Filed under: Everything — cdiggins @ 5:51 am

After one year service, I’m leaving the company.

Let’s just say that I’m not a good fit for Microsoft.

March 8, 2007

Cat Graphics and Effect Systems

Filed under: Everything — cdiggins @ 5:19 pm

I am currently working on a graphics module for Cat. I wanted the graphics module to be easy to use and cross-platform so I settled on generating postscript and pdf files. For example:

 square

This was generated using the following program:

define draw_square {
  [
    dup
    halve dup move
    [dup 90 turn line_forward] 4 repeat
    pop
  ]
  draw_closed_path
}  

define demo {
  new_page
  [2 draw_square 15 turn] 7 repeat
  show_page
}

The way it works is that new_page redirects the standard output to a temporary postscript file, and show_page converts the postscript file to a PDF file and opens it using the default viewer in the shell. So those of you who remember Logo, should immediately see the inspiration for the system.

I figure that most computers have either a Postscript viewer or a PDF viewer, and that I can bundle the open-source ghost script package with the Cat download.

This has been an interesting exercise in that because it involves IO and stream redirection it has forced me to think more in depth about the effect system, and whether it is complete. In Cat functions either have side-effects or they don’t. Any function containing a side-effect has a side-effect, and can’t be moved or rewritten by the optimizer. However the compiler can still break functions up into effect and non-effect components. This is due to the property of Cat that any function can be broken up into two valid functions between any two top-level (non-quoted) terms. In other words { f1 f2 f3 } is the same as { (f1 f2) f3 } and is the same as { f1 (f2 f3) }.

I have been considering the fact that side effects can be easily classified into three categories:

  • local - to a scope, block, function, object, thread, or module
  • global - to the entire program (effects that mess with the entire program … yuck)
  • universal - to the external world

This is not a completely fleshed out hypothesis, but the core of the idea rests on the observation that most of the time IO operations must all follow in sequence to make sense. However when two modules allow state manipulation but are self-contained, it doesn’t matter if I affect module A and module B at the same time. If module A and B ever have universal effects, they have to be coordinate to some degree, with each other (or at least synchornized to the universal effect flow).

All of this seems to have a parallel with concurrency and data flow. In my imagination there is a flow chart of effects, where independant modules have separate paths and module effects occur at key points along the path. Universal effects are like a single path that other paths have to coordinate with at key points. I know it is vague and abstract, but it might give you some ideas what I am dealing with.

I’d be interested in hearing other people’s thoughts on the subject of effect systems.

March 2, 2007

Non-Applicative Languages

Filed under: Everything — cdiggins @ 6:02 pm

The big difference between Cat and other functional languages is that Cat is non-applicative. Functions are composed instead of applied. I am considering writing a paper dedicated to the subject of non-applicative functional languages. The proposed abstract is: 

Non-applicative Functional Languages

Most of today’s functional languages are examples of applicative languages. In other words
the operation of function application is generally implied between two consecutive terms.
This paper explores what it means for a language to be non-applicative, and what the implications
are in terms of basic operations such as the Y combinator.

Any comments on how to improve the abstract? Also is anyone aware of related work besides the Joy programming language?

« Previous Page

Powered by WordPress