Mike Austin's Blog

Tuesday, October 25, 2005

Dylan Inertia screen shot

This is a screen shot of a vector UI library I'm writing in Dylan. I've made a few UI's before, but I started this one with more of a Flash/vector type core, instead of just using rectangles for widgets. The gradient is an effect that can be applied to any shape as in Photoshop 7, and I plan on adding other effects such as drop shadows and bevels. This project has given me a great deal of insight into Dylan.

Monday, October 24, 2005

Vintage Computer Festival 8.0

The eighth annual Vintage Computer Festival will be held on Saturday, November 5th through Sunday, November 6th, at the Computer History Museum in the Mountain View, California.

http://www.vintage.org/2005/main

Saturday, October 22, 2005

Hybrid context menu

I've been writing a kind of vector ui designer in Dylan, and I recently gave a little thought into the use of context menus. Linear menus are ok when you have 5-7 items, but more than that or use of sub-menus makes it hard to use. Regular 'pie menus' are nice when they have a few options, and enable a kind of mouse gesturing, but quickly loose their advantages when more options are needed. Also, I don't like how sub-pie-menus cover up the previous menu in some implementations. So, I've designed a hybrid menu that makes use radial space, but uses regular linear menus for the outside items. It's a bit big, but I'll see how it works out when I implement it. An example implementation of pie-menus can be found here: Java Pie Menus

Wednesday, October 19, 2005

This clip always cracks me up...

Spaceballs - We Passed Then.mp3

Another simple example in Dylan

Here is another example using Dylan, slightly incomplete for brevity.
// Let's define a base class for our objects
define class <actor> (<object>)
// Each slot is initialized in each object instance
slot position = make (<vector>, size: 2);
slot velocity = make (<vector>, size: 2);
slot radius = 1.0;
slot mode = #"normal";
end;

// And here we have a few subclasses of <actor>
define class <ship> (<actor>) end;
define class <rock> (<actor>) end;

// A ship collided with a rock, let's do something
define method actor-collided (ship :: <ship>, rock :: <rock>)
format-out ("Ship collided with a rock!\n");
end;

// No matter what state, advance the actor's position
define method actor-tick (actor :: <actor>, mode :: <symbol>)
actor.position := actor.position + actor.velocity;
end;

// If the ship is in "boost" mode, make it accelerate
define method actor-tick (ship :: <ship>, mode == #"boost")
next-method(); // calls any other applicable methods
ship.velocity := ship.velocity * 1.1;
end;

// Now lets make a ship and a rocks container
let ship = make (<ship>);
let rocks = vector (make (<rock>), make (<rock>));

while (1)
// Advance the ship and each rock, and check for collisions
actor-tick (ship, ship.mode);
for (rock in rocks)
actor-tick (rock, rock.mode);
if (distance-to (ship, rock) < ship.radius + rock.radius)
actor-collided (ship, rock);
end;
end;
end;

Wednesday, October 12, 2005

Programs must be written to be read

Our design of this introductory computer-science subject reflects two major concerns. First, we want to establish the idea that a computer language is not just a way of getting a computer to perform operations but rather that it is a novel formal medium for expressing ideas about methodology. Thus, programs must be written for people to read, and only incidentally for machines to execute. [emphasis is mine]
-- H. Abelson and G. Sussman,
Structure and Interpretation of Computer Programs,
MIT Press 1985.

Tuesday, October 11, 2005

Dylan macro system is badass!

We're not talking C/C++ crapy preprocessors or LISP macros, the Dylan macro facility is a type of BNF translator, able to translate most any syntax or grammar. Behold, I can convert a non-oo looking method definition:
define method move-to (self :: <window>, x, y)
end;
Into this:
define-method <window>.move-to(x, y)
end;
With this little macro:
define macro define-method
{ define-method ?class:name . ?name:name (?params:*)
?:body
end } =>
{ define method ?name (?=self :: ?class, ?params)
?body
end }
end;
Nice!

Saturday, October 08, 2005

Benefits of multi-methods

I've mostly used and played around with C++, Ruby and Python which have no support for multi-methods. Now that OpenDylan is available, I can use it in a language which I admire. Here's how you can respond to an event in Dylan:
define method handle-event( event :: <button-down>, button == $left ) => ()
[...]
end method;

define method handle-event( event :: <button-down>, button == $right ) =>()
[...]
end method;

And here's the equivalent in pseudo-Java:

void handle_event( Event event, int button ) {
if( event.isInstanceOf( ButtonDown ) ) {
if( button == LEFT_BUTTON ) {
[...]
} else if( button == RIGHT_BUTTON ) {
[...]
}
}
}
That is an entangled mess of spaghetti.

Thursday, October 06, 2005

DHTML Arkanoid clone

DHTML Arkanoid is written completely in JavaScript and uses Dynamic HTML. I'm not sure if thats good or bad. :)

Tuesday, October 04, 2005

And He Built a Crooked House

When I think of 1940's science-fiction, I think of tin can robots and flying saucers. Once in a while I'm reminded that this is not the case, and the former is attributed more towards old B rated movies. And He Built a Crooked House is a short story about an architect who builds a house modeled after a flattened 4 dimmensional cube, or tesseract, and after an earthquake, it collapses in on itself, trapping the people inside. I wouldn't have guessed that this story was from 1940.

And He Built a Crooked House by Robert A. Heinlein

Saturday, October 01, 2005

Flash 2D dynamics engine

http://www.cove.org/flade/