Thursday, June 02, 2005

Multi-stage web programming

Something languages like Links may want to keep in mind: there could be a great deal of benefit from taking a multi-stage approach. For the moment, let's make a simplifying (though utterly wrong) assumption that a web application lives in a single page. Then we can see three stages:
  1. The "runtime" is the dynamic aspect of a page that can be scripted with Javascript.
  2. Before that comes the page-generation logic that happens on the server side.
  3. Preceding both these phases is the generation of the static content (the "quoted" part of an ASP or JSP page).
Interestingly, all three of these stages have elements in common--specifically, the DOM. A unifying approach within a multi-stage language could be very powerful. For example, simply quoting an expression in this hypothetical high-level web development language would cause the compiler to change its output from some dynamic Javascript that, say, sets the innerHTML property of a DOM node, to JSP code that generates the HTML on the server.

But now reconsider the above assumption. Real web applications involve multiple round trips, and Ajax is popularizing the further complication of allowing semi-secret (let's never forget the back button, though!) round trips to occur within hidden frames. How does this cycle between the server and client sides change the multi-stage architecture?

1 comment:

單中杰 said...

Possibly related (no pun intended): It is popular to model (in particular, type) staged and distributed computations using modal logic, where ◻φ means "for every client, φ". In categorial grammar and other kinds of substructural logics, ◻ is often written with a superscript ↓ and paired with another modality ◇, such that ◇ and ◻ form a Galois connection; that is, ◇φ ├ ψ just in case φ ├ ◻ψ. Informally speaking, if ◻ means "for every client...", then ◇ means "for some server...".