## Connecting The Dots

It seems worthwhile to connect a few discussions we had recently, and perhaps put them in prespective.

Web programming is becoming more and more important, and many feel there's room for better programming language support for the style of programming is entails. One approach is, of course, to design dedicated (i.e., domain specific) programing languages, such as Links. The other approach is to build application frameworks, but this isn't as easy as it might sound, and depends on the underlying language features, for example continuations (continuations and web programming were discussed here many times).

Ajax style web applications may require multi-language programming, and pose their own set of software engineering difficulties. The Ruby on Rails framework (tutorial) supposedly handles Ajax very nicely, and is causing some developers to move in the direction of Ruby. Libraries and framework often have this effect, and influence language popularity more than fundamental language features. This is quite reasonable since, as we see repeatedly, it is quite difficult to appreciate a language by evaluating language features in isolation.

It might be helpful to consider what Ian had to say regarding Ruby on Rails as opposed to Python web frameworks.

I don't think the important issue at the moment is to decide which language is best. I think it is more important to identify the trends and establish if language design can help improve the state of the art, and if so where.

Personally, I think the answer is yes, and I mentioned some areas of opportunity before, but I'd be interested in hearing what others think.

## Comment viewing options

### Short Term or Long Term?

It's an infrastructure instead of a language game, so:

Short Term
Better support for multi-tier solutions, introspection and codegeneration, serialization of data and code, mobility, http communication.

Long Term
Some multi-paradigm ad-hoc-deployment-supporting secure zero-cost-maintenance type-safely-sandboxed component-version-tracking-and-updating sofware-engineering-documentation-system-including automatically-bug-tracing-to-requirement-and-programmer Ueber-Language.

### infrastructure

Maybe you are interested in an infrastructure called Askemos, which gives you persistant agents (which could be understood as persistant continuations) communicating SOAP messages Erlang-style among each other. Those agents stored in a peer-to-peer network with byzantine synchronisation for each process step. Completed with a administration free permission control system with no central authority and no loss of control. (Thus modelling a democratic constitutional state.) The whole talking http(s) to the rest of the world. At the application level: Scheme and others.

Disclaimer: This is a shameless plug: I'm the principal author.

### The World Is Flat

[That's a book title]

Nice system. Did you write the design out once somewhere?

Funny you named it a democratic system, my analogy was anarchism - one of my brain-trains for the last week was: How to develop programming languages/programs/algorithms which work in ad-hoc globally scaled rulerless environments?

[Ad-hoc as in ad-hoc (mobile/sensor) networks]

### Design paper

There's a white paper which outlines the basic design and some more papers about.

Each agent (web page) is divided into a code and a state part. This code is Scheme at lowest level, state typically XML, but doesn't have to be. Each (byzantine) transaction can update the state and send messages to other agents (think of pi calculus or petri nets, that has been the idea behind). Often the state is XML and the code is an XSLT interpreter (a prototypical one is implemented), than the agent becomes reflexive and maintains it's own continuation. These xslt style sheets are typically divided into three sections: model, view and controller.

Anarchism is hardly a name for it: the most important part is a proof that permission system will not let you loose control (no take over). Anarchism in contrast is about no control ever. Askemos is fundamentally liberal and follows closely the ideas of the enlightment philosophy - because those are the foundation of our legal system.

Originally I just wantet to understand how "intellectual property" could work within our legal framework. So I created a formal model to play with.

Just when I understood that it brought the first tamper-proof processing and moreover in a simple environment, I went further.

Currently I'm sort of stuck: I might be able to model the new european patent law only in "insecure mode". If so, and if the model is correct, this would imply that real patent law is in conflict with "law of nature" (as of J.Locke). But discussion this here is beyond my english skills.

### Reading...

Anarchism is hardly a name for it: the most important part is a proof that permission system will not let you loose control (no take over). Anarchism in contrast is about no control ever. Askemos is fundamentally liberal and follows closely the ideas of the enlightment philosophy - because those are the foundation of our legal system.

I meant anarchism in the etymological sense, it stems from the greek word αναρχία (anarchia) which means, among others, "rulerless". You are right, it doesn't apply to your setting, it was something I was wondering about.

Originally I just wanted to understand how "intellectual property" could work within our legal framework. So I created a formal model to play with.

I totally misunderstood. I thought it was a kind of freenet/content management system... ;-)

Just when I understood that it brought the first tamper-proof processing and moreover in a simple environment, I went further.

Currently I'm sort of stuck: I might be able to model the new european patent law only in "insecure mode". If so, and if the model is correct, this would imply that real patent law is in conflict with "law of nature" (as of J.Locke).

[Don't really follow: you can't distribute patented content?, but...]

Ha! "A state of perfect freedom." Funny, this weekend I read an article in a local newspaper that the second law of thermodynamics was possibly always misunderstood as "maximizing chaos" whereas there are examples where systems by that law "maximize individual freedom" and result in ordered systems.

But discussion this here is beyond my english skills.

Hmpf?, the point of informal communication is that you lay down enough mud for others to see the road. I see more road than mud and otherwise I'll ask.

[Aber, wenn es dir besser gefaellt koenntest du natuerlich auch immer Deutsch reden. Aber nein, dafuer ist mein Deutsch eigentlich viel zu schlecht ;-)]

Ah well, let's not go kuro5hin.

### Devil's advocate

To play devil's advocate, one could say that there is another dot to be connected: Happy birthday, PHP. Even LtU is build on PHP! Wouldn't that imply that a well designed language is one of the less important factor for web programming?

### Patterns

Or was it the best fitting language for a specific infrastructure?

[Hmm, that was just to say - maybe it was just "well-designed" for web programming]

### Sure, but design inheres in a

Sure, but design inheres in a lot of things. If a language is very forgiving syntactically, then new programmers who just want to programme straight away, without a lot of learning or even really understanding will prefer it to something very strict. An example of this is that (h:rest) is a valid pattern in Haskell, while h:rest is not. This seems pernickety, and would put off amateur programmers trying to hack something together (and perhaps professionals as well, justifiably).

### DSLs are not needed for web apps; current PLs are fine.

The problem is that there has not been a good toolkit that allows the creation of web applications. The most important problem is that applications are wrapped inside HTML instead of HTML being wrapped inside applications.

In our company we tried J2EE but the simplest page took weeks to write. Then we stood back and realized that a web application is just like any other wizard-driven model-view-controller application, so we sat down for a few weeks and produced a Java-based web application toolkit that allows for the easiest web programming. For copyright reasons, it can not be shared as open source, but here is the general idea:

1) each web page is composed of 3 elements:

a) the view; i.e. a set of objects organized in a tree fashion that produces the HTML to send to the client. The view-related classes have a classic GUI interface and can be connected to a model instance, just as in Swing.

b) the model; i.e. a set of objects that contain the data. We use hibernate for that.

c) the controller, i.e. an object to called when data are posted.

The web application is composed of the following elements:

a) a WebApplication-derived class that inherits from HttpServlet that does all the routing (I will explain later how the thing works).

b) a set of model-view-controller classes that define page instances.

The web application works like this:

1) in the constructor of the WebApplication-derived class, the programmer registers pages in the form of model-view-controller triplets. The start page is also registered. The above takes place with simple calls that register the classes of models/views/controllers.

2) when a page is requested, the one and only servlet searches its registry and instantiates the proper model-view-controller triad. Each client gets its own triad. The instances are actually stored in the session data.

When a model is instantiated, it is filled with data, usually from a database. Then the relevant view is notified by the Observer pattern, and the view is transformed to HTML and send to the client.

3) when a post is made, the one and only servlet instance reads the posted data, updates the view, which in turn either updates the model which in turn invokes a controller (or a controller is invoked from the view). Then the controller returns the class of the page to instantiate.

The WebApplication-derived class also does a few more things automatically:

a) it redirects HTTP requests to HTTPS if the URL is for HTTPS and vice versa.

b) it does not allow the user to break the application by not allowing a page to be instantiated if not in the work flow.

No XML is ever used (except for setting up the initial servlet), and we have made an Eclipse plug-in that converts HTML pages to our View GUI classes, therefore totally separating web design from web programming.

We have seen an increase in productivity in 1000% in some cases, since the GUI application is actually validated by the compiler, and we don't have to worry about who has the data, how is the data rendered, how to extract the data etc. And it is all Java, without XML and without other types of quirky things, without needing to know thousands of tags etc.

The next step in this toolkit is extend the GUI by providing classes that create JavaScript, so we can have better pages.

After all this, my opinion is that the main problem with J2EE and all current web technologies is that programming languages are wrapped inside HTML, whereas it is the reverse that should take place.

### But then you've lost the simplicity...

...of being able to treat the web pages as independent entities, by having them become tightly coupled with the code/library. And you've made the generation of web pages become a java programming task. The programming end is made easier at the expense of making the manipulation of the data (html) harder. In some cases, the programming is the hardest chore, so that might make sense. In other cases, the manipulation of the data is the hardest part. And what's easy and hard will not vary just between projects, but also within any given project.

Three different types of framework come to mind. First, you can embed a little server side script in your pages, ala php, jsp, or asp - the presentation page is the master. Second, you can just generate the html from within the programming language of choice - such as you've done with Java (and how most of the original Perl CGI scripts were authored).

Or you can use a Template type scheme where there is a both a web page master and a bean master, trying to use each to it's best ability. This is the method used by the more recent vintage web frameworks (lot's of various Tomcat plugins, Mason, Zope).

I haven't studied Ruby on Rails or Ajax, so I'm not sure where they draw the lines in the divide and conquer strategy. But developing your own framework has some costs that have to be factored in. First, there is the cost of writing and maintaining your own libraries. (If an alternative is available, then you are just reinventing the wheel). Second, any new developers brought in have to be oriented towards the in-house framework, not being able to leverage off of their experience with other companies that use a more common framework. Finally, there is the problem of transitions, in that you can not leverage off of incremental improvements that are done by those who specialize in framework development. If a new feature gets added to Ruby on Rails that you want to use, you have to do some reverse engineering and program a parallel solution in your framework.

This is not to say that roll-your-own should be avoided. In some circumstances, it is the best thing to do (control your own destiny; optimized for you domain; knowledge and insight gained). But these things do have opportunity costs.

Finally, I am wondering why you chose Java? Just to up the ante one more level: If you can do these things via libraries within a programming language, then wouldn't it also make the most sense to use a language that optimizes our productivity? Perhaps Java does do that, but then the original reason for widespread adoption comes into question. Server side apps can be written in any language (Smalltalk, Scheme, Perl, ....). Why did we have to go through the motions of coming up with yet another half-baked programming language? The answer to this question might give you some insight into why people have been searching for new frameworks wherein the language use is a secondary or tertiary prerequisite.

### HTML-in-PL or vice versa

After all this, my opinion is that the main problem with J2EE and all current web technologies is that programming languages are wrapped inside HTML, whereas it is the reverse that should take place.

I completely agree with you except for the "all current web technologies" bit. Continuation-based web servers like the PLT server, Seaside and UnCommonWeb have had the pattern of an overall program that displays web pages as part of its execution for several years now. Having used the PLT server quite a bit after moving from ColdFusion, PHP, and a few other more traditional web frameworks, I agree 100% that the notion of having a web page with code on it rather than a program that spits out web pages was a bad bad idea and really ought to go away.

### Ajax, Barcelona, Cruyff

[ The proof is there: everything in the world reduces to Cruyff ;-), another offtopic book title ]

OT thought: Dunno. Looking at something like TiddlyWiki, I can't help but wonder how it would be if you would Ajaxify it.