Fridge magnets have been my playground web application while learning Erlang. The basic idea is some letters which you can drag around to form words or whatever. It is made a little more interesting as users all use the same set of letters, and so users see letters being moved by other users.

The application itself isn't particularly interesting, there has been a Flash version of this for a long time. Of course there are a couple of things I find interesting about building such an application.

Web browsers have traditionally been geared to making requests and receiving responses. When there is the need to go beyond that to more persistent connections there are several options (and combinations of these options)

At some point since I last used App Engine, Google have added a Channel API for persistent connections. The App Engine and Python are quite fun to play with, so I decided to hack together a version of Fridge Magnets using the API.

As Google serves the JavaScript and the handlers for the persistent connection they could use any of the techniques. It appears they are only currently doing long-polling.

The app is at gae-letters.appspot.com and the source on bitbucket.

It's all a bit hacky, but it weighs in at less than 150 lines of Python so I'm not too worried. While it was fun and pretty easy, there are some pretty seriously limitations of App Engine when trying to build such applications.

Although didn't use the Task Queue API which looks very useful, it seems traditional web frameworks suck for building this type of application. Alternatively Erlang and probably Node.js and Twisted etc are made for it.

Hopefully a robust, fast Erlang implementation will be the topic of my next post.

Comments

Comment