November 28, 2007

Meet MARIA: The Maintainable And Rich Internet Application

Currently, building a MARIA is quite a challenge. A Rich Internet Application (RIA) is often put together using a mixture of languages: Javascript+HTML+CSS+SOAP+XPATH+PHP+... Of course, many RIAs are short living, disposable applications as they are often built for a certain event and need only to last for a short period. Maintenance is not a large issue then. But it is for the RIAs that are supposed to last.

Writing Ajax based RIAs without a reasonably sophisticated Ajax framework usually results in a maintenance nightmare, let alone all the browser compatibility issues you will undoubtedly need to solve. Ideally, you never write even a single line of Javascript. However impressive some of the Ajax based RIA frameworks are, it is still limited to the possibilities of DHTML. Adobe's Flash Player is far better suited for running RIAs than DHTML.

Adobe's Flash Player is a ubiquitous platform for smooth and sexy web applications. Since version 9, it is called Flash Virtual Machine. It resembles the Java VM in several ways. Like the JVM, it provides for garbage collection, remote debugging and uses JIT compiling. The Flash VM was designed and optimized specifically for Rich Internet Applications built with Adobe Flex.

All development tools of the Flex SDK are built in Java. Adobe also provides an expensive but impressive serverside framework, entirely based on Java for connecting Flex applications to Java backends: Flex Data Services (FDS). A good and very affordable alternative for FDS is MidnightCoders' WebORB.

A Flex application usually consists of a set of UI component specifications that are written in an HTML-like markup language (MXML) and a number of classes written in Actionscript for handling events and doing client side processing. Since Flex version 2, ActionScript 3.0 is used. AS3 is a mature, object oriented programming language that is fairly easy to learn for Java developers. However, there is one annoying difference which lies in the way variables and class methods are declared. In action script, you declare a local variable like this:

var x: int;

whereas in Java, you are used to writing this:

int x;

A class method in Actionscript looks like this:

public function square(x: int): int {...}

You know what the Java version will look like. I think you see my point.

There exist other RIA frameworks that create shockwave binaries. The best known alternative for Flex is OpenLaszlo, which is also entirely built in Java, and supports most J2EE Application Servers.

So, developing a Flex based RIA including the required backend services requires your team to use at least three different languages: one for specifying the UI components, one for client-side event handling and processing and (hopefully) one for all the backend stuff.

It would be most ideal if it were possible to use a single programming language for all layers of your application (backend to frontend). The Google Web Toolkit gets you a good way in that direction. You write (and debug) your RIA in Java, and compile it to Javascript (a native javascript for each supported browser). Very cool. I wonder, when will Google introduce a Java to shockwave (Flash) compiler?


Waldo said...


it's not always obvious for everyone, but if you prefer not to use MXML for the view of your app, you can just ignore it. If memory serves well there's nothing or almost nothing you can do in MXML that can't be done in code (hey, the MXML compiler compiles into ActionScript anyway ;-) ). It's just that MXML often is more convenient and seems easier to be supported by design tools.

Mark Nankman said...

Thanks for pointing that out, Waldo. I think, for the sake of maintainability of a Flex application, that I would even prefer MXML above Actionscript for writing views and other components.