Read on and leave a comment
or return to our portfolio.

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

26 May 2005

by Noel

PLT Blog Watch

I’ve just become aware that a lot of the PLT crew are keeping blogs. Worth checking out if Lambda the Ultimate doesn’t provide you with enough daily programming language theory are:

Jacob’s blog is particularly interesting to me for two reasons:

  • He’s talking a bit about commercial applications of PLT Scheme, something that we’re trying to do at Untyped
  • He’s got a great paper showing how a pile of programming language theory can be applied to solve a problem way better than anyone else has solved it before, which is something we’rereally into!

Posted in General | Comments Off on PLT Blog Watch

25 May 2005

by Noel

How Did They Do That?

Xyle looks like a nifty tool for working out how a CSS design was created. It only works on Safari, so for most people the Web Developer plugin for Firefox will be more useful. Xyle does have a few features that WD doesn’t, so if you have Safari and the $15 I’d say it’s worth it.

Posted in Web development | Comments Off on How Did They Do That?

10 May 2005

by Noel

Dashboard: A Great Move, Even Though Apple Got It Wrong

One of the highly talked about features in Tiger is the Dashboard. Basically it is a platform for little widgets coded in Javascript and CSS; things like calculators and email notifiers. At least that’s how Apple present Dashboard, and they’ve got it wrong.

To see the true importance of Dashboard we need to look at what makes Microsoft the dominant player in the computer industry. Microsoft makes most of its money from the sale of Windows and Office. Now the only reason to buy Windows is for the applications that run on it. So long as Microsoft controls the largest pool of developers Windows remain the number one OS.

It seemed that the web threatened Window’s dominance, by making the platform irrelevant. Microsoft realised this a long time ago, which is why they killed Netscape and then promptly stopped development on IE. Now browsers have continued to get better, thanks largely to the efforts of Mozilla, but yet Microsoft continues to prosper. The reason: web-based interfaces, compared to their native counterparts, suck. Right now we’re seeing some exciting developments. Starting with Oddpost and continuing with GMail and other so-called AJAX applications, web-based applications have been delivering interfaces that approach their desktop counterparts, but they aren’t there yet.

This is where Dashboard fits in. It lets you deliver rich interfaces using Javascript, HTML and CSS, principally via the canvas extension, which is independent of Dashboard per se (it works in Safari and any other WebKit application). This is a huge win for Apple. There are thousands of people who don’t know any Objective-C but do know web technologies, and now they are all potential OS X developers. Web applications are only going to grow in number, and enhancing an existing web application with a Dashboard interface isn’t that much work, so Dashboard has the potential to make OS X the preferred platform for delivering rich interfaces. Additionally, using skills learned from web development, people can start developing Dashboard applications that have nothing to do with the web. Unfortunately Apple has marketed Dashboard as a platform for little toys, not serious applications, but I think its potential will become apparent as people explore it further. And when they do Apple might finally have the momentum to seriously tackle Microsoft’s dominance.

Posted in Web development | Comments Off on Dashboard: A Great Move, Even Though Apple Got It Wrong

26 Apr 2005

by Noel

In The Beginning…

Everything must have a beginning. This is ours.

Posted in General | Comments Off on In The Beginning…