Hot Potato!

Hector and I have been busy – check out what we made the other day: it’s a game of Hot Potato!

It’s a quick and dirty, one-day fun app.

This uses the refresh code featured in the previous post, Check This Out. It’s very simple, and very crude – but it only took 12 hours to make.

Of course, there are more efficient ways to write interactive, low-latency web apps than by refreshing the whole page every four seconds. But the problem is, efficiency takes more time. The more bandwidth you want to save, the more work you have to do. I’ve got Node.js and socket.io, you’ve got Juggernaut or Socky, I could even just return a JSON feed that only returns the necessary data, and render that. Now that the app’s built, I can use whichever technology I like – when I feel like making it faster.

The app runs on Heroku, though – so an hour’s good performance is only a couple of clicks and a couple of dollars away. For such a trivial app, what’s the point in adding sockets? I’m not paying for traffic, or setting up more servers, or anything. I just want it to be as quick to build as possible.

It’s premature optimisation all over again – if it works the ugly way, go from there. Recently, I built a mobile drawing application for an art installation. For technical reasons, we had to draw into a canvas element, on a Nokia N900 phone. This meant installing browsers, trying plugins, trying javascript, trying sockets, xhr-multipart, polling… the lot. It all worked fine in the office, and it all worked fine in Soho – but none of that shit worked over 3G. What worked? Doing a big poll every 4 seconds. That was robust enough to either make the request properly, or fail and try again later. Sometimes that’s all you need.

I wouldn’t recommend this approach if you expected to get any traffic, or if you had a budget or a timeframe – but sometimes it’s great to just make it work. When it comes down to it, the end-user can’t tell the difference. At an early stage, or with a small product, you’ve got much more important things to think about than performance.