I was alerted to some activity happening around pyjamas recently on usenet. For those of you who don’t know, pyjamas is a compiler that translates python code into javascript. It was originally started as a port of GWT project but appears to have taken a life of it’s own. They’ve not only added more widgets; they’ve added JSON-RPC support and even the ability to port pyjamas projects to the desktop!
Pylons is a great web framework that I have been working with for the past five or six months developing the new version of fotoglif in. There are lots of great things about the framework that I can rave about, but the interesting one for this post is that they include an XMLRPCController base class that you can use to create an XML-RPC service with. However, it doesn’t have a JSONRPCController.
So I started putting one together last night.
I then got to thinking that I should probably create a setuptools command to compile the UI code before creating a distribution package. Of course then I’d need to create a paster template to setup a pylons project with the custom command… and perhaps lay down some initial directories where I can store my UI code. Then it began to dawn on me.
I could write my next web application as if I were writing for the desktop.
One thing I’ve despised over the years building web applications was the constant switching across entire areas of expertise. One minute you’re optimizing SQL queries, caching your lazy-loads; the next you’re writing javascript code to smooth over some cross-browser bugs in your interface. There’s just so much that specializing is hard to do which means getting really good at any one thing is hard to do (unless of course you’re working on a large team with an excellent communication infrastructure). I find that as a philomath, I didn’t mind so much as learning new things is what gets me up in the morning. But some times it becomes really frustrating. I’ve always wished I could just write interface code for the desktop: the web was just not cutting it.
However, we have to be careful not to forget what’s really going on here. Pyjamas is great, but it’s just hiding the fact that it’s generating unfathomable amounts of code. Messy code. Complicated code. One of my chief complaints against GWT is that its browser support is extremely limited and has no hope of ever degrading gracefully for clients that cannot support the javascript it emulates. Accessibility also becomes slightly more complicated.
So we have to take it for what it is. AJAX-based interfaces are not going to go away and as demand for ever-more-complex interfaces rises on the web, we need tools that can help us reduce the overall complexity of delivering them. I think Pyjamas shows promise and like GWT, is a step in the right direction… a first little baby step. Yet you can’t stop progress and the compilers will get better. New solutions will be dreamed up.
For now, my next step will be to finish wrinkling out the bugs in this JSONRPCController class and submit it to the pylons crew for review. Then I can start messing around with integrating pyjamas into my next project and seeing how well the JSON-RPC support works. Updates will follow in the next few days…