I've found a new way of writing web applications and couldn't be happier. HTML pages are all static, nothing generated server side. Everything dynamic is done via Javascript in the browser. I know I'm a few years late to the AJAX party, but I really like how it works so I thought I'd share some thoughts.

The new app is a nerdy game thing: graphs of Warhammer PvP history. There's a server backend scraping web pages and creating a historical database. The main user page is a graph rendered entirely in the client, using AJAX to load the data from my server and the Protovis Javascript library for the rendering. In the old days I would have generated HTML and an image in my server. Now, like my WikiHere demo, the server isn't doing anything complex.

The main advantage to this approach is development speed. I can fine-tune the presentation just by editing the HTML and Javascript. I don't even need a web server to test. My dev code is my live code; no translating back into JSP or whatever nonsense I used to do. That's a particular advantage for big software projects, the UI team can do real work and not just mockups.

There's other advantages too. Testing the server is a lot easier; all its doing is returning JSON blobs. The server is easy to scale since it's doing so little; in my case I started down this path because Google App Engine doesn't really have a good way to do server-side graphs. Caching is easier; generic JSON business objects instead of some over-customized generated HTML. And the JSON API the server implements can be used for other presentations.

The only major drawback I've found with this project is supporting Internet Explorer. Every other web browser in the world implements Canvas and SVG, letting Javascript beautifully render pixel and vector art. But not Microsoft. The medium-term solution may be be excanvas and svgweb, emulation libraries for adding the features that Microsoft was too lazy (or evil) to implement.

So now I have a new way to build webapps. The server becomes a simple business logic API server. Javascript code does all the presentation work. It's a fun way to code.

  2009-09-19 15:14 Z