Archive for June, 2005

30 Jun 2005

by Noel

A bit more art: Fluxus

Untypers keep their eyes on a number of weblogs; one of them isLemondoor, a LISP-related weblog maintained by jjwiseman. In this post, he points us at Fluxus, a very cool looking real-time coding and live-performance engine for sound and visual effects.

http://www.pawfal.org/Software/fluxus/

We don’t like to blow our own horn too hard, but around untyped we do pretty well with a number of languages, and Scheme is a favorite; we have a number of open-source projects written in Scheme, and it drives some of our own research projects as well. Fluxus looks like the kind of platform that we might be able to do some very fun and exciting things with.

Posted in General | Comments Off on A bit more art: Fluxus

30 Jun 2005

by Noel

Aspects in Javascript?

I just read about an interesting library for using CSS selectors to apply Javascript behaviours, courtesy of a link from Ajaxian. The idea is simple: use CSS selectors in Javascript code to specify DOM nodes that Javascript event handlers should be bound to. This abstracts the event handling code away from the HTML. This gives cleaner code, though I’m not sure how useful it will be in practice, for two reasons:

  • It will be slower than just writing the event handlers directly in the HTML. How much slower I haven’t measured, so this may not be a problem.
  • I don’t write much Javascript directly (except when trying out new ideas). Instead I tend to generate it (along with HTML) from other sources, so achieving a separation between Javascript and HTML isn’t an issue for me.

However I don’t want to give a negative view of this library. I think it is really neat, and it has interesting similarities to Aspect-orientedprogramming (AOP). In AOP you change code by specifying places to add extra functionality. This library is changing HTML by specifying places to add extra functionality. If you squint the right way HTML and Javascript merge into one, so there seems to be a relationship here. I don’t know enough about AOP to know if this analogy opens up any interesting new directions, but I know people who do, and I hope they’re going to comment on this. :-)

Posted in Javascript | Comments Off on Aspects in Javascript?

29 Jun 2005

by Noel

Achieving Closure

Todd Ditchendorf advocates the benefits of anonymous classes:

While the XMLHttpRequest class is certainly a major step forward for JavaScript in the browser, you have to admit… this API is crap … Instead of passing a function reference to [the XMLHttpRequest object], why not pass a reference to a JavaScript object? … Notice how [anonymous classes] allow you to package instance properties (fields, variables, attributes, whatever) and instance methods along with the actual callback method … Sure … you don’t need this kind of functionality … you can always just define a bunch of global functions and global variables to be used by your callback function, but, then you lose all the benefits that OO offers with regard to combining state and behavior into a single, encapsulated entity!

While I agree with his statements — the XMLHttpRequest API is crap — the alternative to anonymous classes is not a mess of global variables and functions, thanks to a feature in Javascript known as closures. It seems many Javascript developers don’t know about closures, as they come from the functional, not object-oriented, line of languages, so I thought I’d highlight them here.

Javascript allows functions to return functions, and I think most Javascript developers will be familiar with that. However, some may not know that such a function can reference variables defined in it’s parent function, even after the parent has returned. This means you can write things like:

function makeSayHello(name) {
var sayHello = function() {
alert("Hello " + name);
}

return sayHello;
}

var noel = makeSayHello("Noel");
var matt = makeSayHello("Matt");

noel();  /* Says "Hello Noel" */
matt();  /* Says "Hello Matt" */

Notice that noel and matt refer to the arguments to makeSayHello even after makeSayHello has finished executing. This is very useful when writing callbacks, as it allows you to setup the callback with the parameters it needs avoiding a mess of globals. For example:

function makeCallback(arg1 arg2) {
return function() {
doSomething(arg1);
doSomething(arg2);
}
}

You’ll see this pattern used a lot in our demos. It’s a neat trick and deserves to be better known.

Posted in Javascript | Comments Off on Achieving Closure

17 Jun 2005

by Noel

Those Who Wonder Wrap-Up

On Monday Christian and I went to Those Who Wonder, the degree show for the Graphic and Media Design (Illustration) students from the London College of Communication. In a word: Wow!

There’s something wonderful about degree shows. The students realise they’re on the cusp: they’ve finished their training and soon it will be time to try and make an impact on the world outside the University. In some ways it’s the best of times, when everything is potential and no limitations are set by the disappointments that from time to time life brings. It’s been, well, too many years since I finished my undergraduate eduation, but I recaptured a bit of that feeling by being there.

Ostensibly an illustration course, the show included a variety of work that stretched the definition of illustration to the limit: t-shirts, masks, books, and even videos. I was very impressed. The students had also organised and paid for the whole event, including renting the gallery and organising the drinks and entertainment. I can’t recall Computer Science students ever organising an event to equal this!

We took some photos; they’re on Flickr under the thosewhowonder tag. They don’t really do justice to the vent. There were many cameras at the event so I’m hoping that Nils will be able to get some better photos uploaded.

Of course I have to mention the electronic catalogue we developed for the show. It worked wonderfully!

Posted in General | Comments Off on Those Who Wonder Wrap-Up

17 Jun 2005

by Noel

The Canvas: Why It’s Important

In Safari 1.3 Apple introduced a new canvas tag along with Javascript extensions that enable 2D vector graphics to be drawn directly onto a web page. This extension has since been incorporated in aWhatWG specification and Mozilla have followed up with an implementation that’s available in the latest Firefox 1.1 preview release. We have two demos up here and here. This essentially enables a lot of the power of Flash from within a normal web page.

Apple’s motivation to was to enable Dashboard, but as we discussedearlier the potential for this technology extends much further. Existing web technologies such as CSS, the DOM, and Javascript allow highly interactive applications, as GMail and Google Maps have shown. However there are still some limitations: the developer cannot create custom widgets or draw complex graphics in the web-browser. The canvas solves this problem. Now that Firefox is implementing the canvas it makes it viable to release cross-platform graphic rich applications. This is a whole class of applications that so far the web hasn’t been able to touch. Think about Adobe Illustrator running within your web browser. This is one to watch!

Posted in Web development | Comments Off on The Canvas: Why It’s Important

10 Jun 2005

by Noel

A bit of art…

Untyped recently had the opportunity to work with Nils Porrmann on a piece that is part of the upcoming Those Who Wonder exhibition showing this weekend.

Nils and his conspirators had developed a number of pieces they wanted to present in a book, but did not like the idea of printing dead-tree versions of the book for everyone who came to the show. The brainstorm was to take a video of the book, and have some way for the viewer to turn the pages of the video/book by waving their hands in the air… or some other apparently magical mechanism.

Christian and I were able to make that magic happen, and the end-result is really quite nice (even if we do say so ourselves!). Our first step was to explore an excellent little application calledEvoCam; this program lets you plug in an iSight video camera, drag-and-drop regions on the video, and attach actions to motion detected in those regions.

From there, it was just a hop, skip, and a jump to controlling the video. We wrote a custom application for Nils to easily mark the page-flip points, which we then fed into the AppleScripts for controlling the player. The true genius came from Nils, who realized that the interface to a virtual book should be a real book. So, the viewer turns the page on a real (but blank) book, and the video follows the action. With a little skinning of Quicktime Player, we eliminated the control surfaces, and it looks just great on a black background.

We don’t get to do things like this often enough; we like to think that programming is an art, but how often do we actually get to make art with our programming? When the show goes up, we’ll get some pictures and video of the… video. It will be great to see people interact with it!

If you’re in London this weekend, please feel free to stop in. The whole show looks like it will be great.

Posted in General | Comments Off on A bit of art…

9 Jun 2005

by Noel

New Design

As you may notice, we have a new design that fits in much better with the design of the rest of the site. Enjoy!

Posted in General | Comments Off on New Design

1 Jun 2005

by Noel

Google Summer of Code

Google Summer of Code will pay you $4500 if you complete an open-source project over summer. Only two questions:

  1. When will PLT Scheme join the list of participating organisations?
  2. Where do I sign up?

Seriously, Untyped and other ventures are keeping me busy enough that participating isn’t really viable. However this does look like an excellent opportunity for both OSS projects, and developers with free time.

Posted in General | Comments Off on Google Summer of Code