Archive

Posts Tagged ‘pyjamas’

Pyjamas or Django on the Desktop?

February 23, 2010 Leave a comment

Reservations about Pyjamas

First, let me state the obvious:  A lot of developers have a huge desire to be able to code once and run on both web and desktop.  This is a good desire.  The question is:  How do we do this practically?

Microsoft has done a lot with .Net and drag-and-drop programming.  However, in my experience, this is bulky and very limiting.  I usually have to hand-code most of the interesting bits anyway.  (For example, I have often hand-coded the data access layer.)

A huge selling point for .Net is that it does a lot of the cross-compiling (aka, javascript generation) for you.  This is advertised as making it easier to do a lot quickly.  Also, this allows me as a developer to forget that I’m actually targeting javascript, even though I’m writing in a .Net language.

The truth is that this works, as long as you stay within the boundaries of what it is built to do.  You’re fine, if you never need to debug your client-side code.  But, as soon as you want to tweak something seemingly-inconsequential, you’re often back to hand-coding javascript.  And, most often, there’s no way to go backwards; IDEs that generate javascript for you very rarely decompile it back to the language you started with.

I’ve just picked on Microsoft (easy target, I know).  But I have the same questions about pyjamas, or any other cross-compiling library out there.  Here are some serious questions to ask about pyjamas:

1. Does it decompile javascript back to python for you? (In other words, will it allow “round-trip engineering”?)
2. Does it allow you to control how it generates javascript from your python? (And is that easy to do?)

One other small reservation is this: Cross-compiling tools are meant to generate functionally-equivalent code for both web and desktop.  But in reality, the two platforms actually run different code.  This makes me uneasy.  It “feels” fragile and unpredictable.  I wish I had something more concrete to say, but all I have is a gut feeling on this one.

Another option: Django on the Desktop

I’ve done a lot of work with Django recently.  I’m very impressed by this framework.  One of Django’s main strengths is the stringent application of the Don’t Repeat Yourself (DRY) principle.  That makes development in Django both fast and fun.

Django includes a built-in webserver, intended for use while developing on your local box.  The server runs so well, that it got me thinking:  We could deploy Django applications to the desktop!

This idea is fundamentally different from the cross-compiling idea.  Essentially, it says, “Never run desktop apps.  Just run web apps, but serve them from the desktop.”  You get to use the exact same skills that you use building websites.  You run the exact same code.  And, you know exactly what you put into that code.  (Granted, you have to hand-code some javascript, or jQuery.  But you probably do that anyway.)

Granted, some applications need intense processor speed and memory.  But, are those the kinds of applications that would work well on the web via a cross-compiling toolkit, anyway?  Maybe.  And maybe there is still a need for cross-compiling tools.  All I’m saying is that a lot of business applications would do very well in a desktop-server model.

I’ve had this idea for a while, but no real time to invest in it (yet).  So, I’m just going to leave it there.  If you’d be interested in working with me on a Django-on-the-desktop project, let me know.

Thanks for reading this far.  I welcome your feedback. 🙂
JSA

PS-Isn’t the word “pyjamas” from language in India originally?  I once had two very comfortable Indian-made pyjamas. Better than any long-sleeved shirt you could buy in the States, IMHO.

Categories: Articles Tags: , , ,