📜 ⬆️ ⬇️

An overview of modern technologies for creating RIA applications

Introduction


A few years ago, in the field of creating Internet applications, there was a tendency to move from standard HTML / JavaScript / CSS technologies to platforms that allow you to run programs in a web browser environment that are not different from windowed (desktop) applications. This type of software products is called Rich Internet Applications ( RIA ), which means “rich Internet applications”. Despite the fact that some of the RIA technologies were released quite a long time ago (late 90s), they were widely distributed no more than 3-4 years ago.
Talk about the features of the RIA should start with conceptual differences from HTML based applications. Regular services sites operate on the principle of switching to another page via hyperlinks and sending a form to the server using a web browser. In other words, the work of such applications is concentrated around a client-server architecture with a thin client . HTML, being a markup language for documents and displayed by the browser, is ideal for this. The sequence of user actions is the constant sending of requests to the server. With this approach, there are a number of problems:
  1. Saving user data between application sessions and synchronizing them with the server.
  2. The problem of sending and receiving data from the server only as needed, and not for every user action.
  3. The problem of running the application when not connected to the network.

What solution of these problems does the RIA concept offer? From an architectural point of view, it translates such programs into a category of applications with a fat client. All RIAs have a similar feature: the presence of an intermediate part that is transmitted over the network to the client and is responsible for interacting with the server and displaying the user interface, which is far superior to HTML counterparts. In Figure 1 you can see the principles of the organization of interaction with users in the case of HTML and RIA applications.
image
Figure 1 - Principles of HTML and RIA-applications
The solution to the problem of saving user data occurs at the expense of the RIA platform (platform-independent environment for launching RIA applications). The intermediate part downloaded from the network refers to it for saving and reading information. From here it is possible to send and receive data from the server only as needed, due to caching on the client side. The issue of unstable connection is also resolved. RIA platforms can install the application on the user's computer. This means that disk space will be allocated for program files and it can be launched without a network. Thus, it is possible to note the main distinctive features of the RIA:

The gradual development of Internet standards has led to the implementation of such technologies in practice. The most famous at the moment are the following:
Title
Manufacturing company
Date of issue

Google Web Toolkit (GWT)
Google Inc.
2006
Adobe Flex / AIR
Adobe Inc.
2008
Javafx
SUN / ORACLE
2009
Silverlight

Microsoft Corporation
2007
Java Applets
SUN / ORACLE
1995

Table 1 - Most Common RIA Technologies
')
The choice of these products is due to the prevalence of the Internet and the fact that users have installed platforms for launching RIAs. In the following sections, compact applications will be created to demonstrate the basic technical features of each technology. The task of the programs is to obtain a brief statistics on the load of the application server after certain periods of time and display it to the user. In response to each request, the server sends the following data, packaged in JSON :

In this way, the client parts of the demo applications are different, and on the server side their requests are serviced by a Java servlet.

Application on GWT


A brief description of the technology. The RIA developer creates the interface and logic of the program in Java, and GWT compiles the source code into carefully optimized JavaScript. The script file connects to the webpage and displays the application interface during the download. At the same time, firstly, the problem of having a special browser plug-in is solved - in fact, in the case of GWT, it is necessary to enable Javascript scripts (supported by all modern browsers). Secondly, GWT has a large library of components to create full-fledged RIAs, and their number is constantly growing, thanks to a large developer community. Based on these components, you can make traditional window interfaces in the browser.
Benefits:

In addition, while working in Java, you can use:

As for the contents of the libraries, the GWT includes:

disadvantages

Application code snippet
currentRequest = requestBuilder.sendRequest(query.toString(), new RequestCallback() {
public void onResponseReceived(Request request, Response response) {
pleaseWaitLabel.setVisible(false);
if (response.getStatusCode() == 200 && response.getText() != null && !response.getText().equals("")) {
JSONValue resVal;
JSONObject resObject;
JSONString serverName;
JSONNumber totalMemory;
JSONNumber freeMemory;
JSONNumber maxMemory;
JSONNumber threadCount;
try {
resVal = JSONParser.parse(response.getText());
} catch (JSONException e) {
Window.alert(" . ");
return;
}
if ((resObject = resVal.isObject()) == null) {
Window.alert(" . ");
return;
}
if ((serverName = resObject.get("serverName").isString()) == null) {
Window.alert(" . ");
return;
}
…..............................................................................................................
setServerName(serverName.stringValue());
setTotalMemory(Integer.toString((int) totalMemory.doubleValue()));
setFreeMemory(Integer.toString((int) freeMemory.doubleValue()));
setMaxMemory(Integer.toString((int) maxMemory.doubleValue()));
setThreatCount(Integer.toString((int) threadCount.doubleValue()));
} else {
Window.alert(" . ");
}
}
public void onError(Request request, Throwable exception) {
pleaseWaitLabel.setVisible(false);
Window.alert(" . ");
}
});

Flex / AIR application


A brief description of the technology. Adobe Flex is a toolkit for developing RIAs on the Adobe Flash platform using ActionScript 3. Flash provides far more options than you can get from HTML in terms of interactivity. Nevertheless, Flash development is a very difficult process for simple programmers. Flash targets designers more. Flex removes this barrier by providing a software way of developing an RIA. MXML , an XML-based language, is used to describe the user interface format and behavior, and ActionScript ™ 3, a powerful object-oriented programming language, is used to create a logical model for the behavior of a client program.
Benefits
RIA applications created in Flex can work in a browser using Adobe Flash® Player software, or as a regular program if the OS is running cross-platform Adobe AIR ™ application. Because of this, Flex applications can work with many common browser types as well as with desktop operating systems. When using AIR, Flex applications can access local PC data and system resources. However, the AIR security model will not allow damage to user information and system files by running applications in an isolated environment. Flash Player and Adobe AIR are available for free download on Adobe.com. Currently, 99% of PCs have Flash Player with one of the most recent versions (9 or 10). The user interface is created using MXML, a relatively simple and intuitive language, so experienced developers can learn it quickly.
disadvantages

Application code snippet
<mx:HTTPService
contentType="application/x-www-form-urlencoded"
id="service"
method="GET"
resultFormat="text"
showBusyCursor="true"
url="/status"
fault="httpFault(event)"
result="httpResult(event)"
useProxy="false"
/>
public function httpResult(event:ResultEvent):void {
//get the raw JSON data and cast to String
pleaseWaitLabel.setVisible(false);
var jObj:Object = JParser.decode(event.result.toString());
serverNameValueLabel.text = jObj.serverName;
totalMemoryValueLabel.text = jObj.totalMemory;
freeMemoryValueLabel.text = jObj.freeMemory;
maxMemoryValueLabel.text = jObj.maxMemory;
threadCountValueLabel.text = jObj.threadCount;
}
public function httpFault(event:FaultEvent):void {
Alert.show(" , ");
timer.stop();
}

Java applet application


A brief description of the technology. A java applet is a byte-code java application. Java applets are executed in a web browser using a Java Virtual Machine (JVM), or in Sun's AppletViewer, a standalone applet testing tool. Java applets were introduced in the first version of the Java language in 1995. They are created in the Java programming language, but can also be written in other languages ​​that are compiled into Java byte code, such as Jython.
Benefits

disadvantages

Application code snippet
private void updateServerStatus() {
clearStatistics();
pleaseWaitLabel.setVisible(true);
Timer t = new Timer(3000, new AbstractAction() {
public void actionPerformed(ActionEvent actionEvent) {
try {
pleaseWaitLabel.setVisible(false);
URLConnection conn = new URL(url).openConnection();
String json = readStreamToString(conn.getInputStream(), "UTF-8");
JSONObject j = new JSONObject(json);
serverNameValueLabel.setText(j.getString("serverName"));
totalMemoryValueLabel.setText(j.getString("totalMemory"));
freeMemoryValueLabel.setText(j.getString("freeMemory"));
maxMemoryValueLabel.setText(j.getString("maxMemory"));
threadCountValueLabel.setText(j.getString("threadCount"));
} catch (Exception e) {
e.printStackTrace();
}
}
});
t.setRepeats(false);
t.start();
}

JavaFX application


A brief description of the technology. JavaFX is a platform for creating RIAs that can run on personal computers and mobile devices. JavaFX technology allows you to create applications for working with multimedia content, graphical user interfaces for business applications, games for personal computers and mobile devices, rich graphics, multimedia websites, etc. JavaFX applications are created using the declarative programming language JavaFX Script. To develop applications in the JavaFX Script language, you need to download and install the JavaFX SDK. From code written in JavaFX Script, you can access any Java library. Therefore, the joint use of Java and JavaFX Script languages ​​allows solving various tasks, for example, the logic of a business application can be written in Java, and the graphical user interface can be written in JavaFX Script. Applications written in JavaFX Script can run on computers with installed Java 1.5 and higher. The following operating systems are currently supported: Windows, Mac OS X, GNU / Linux and Solaris.
Benefits

disadvantages

Application code snippet
var parser = PullParser {
documentType: PullParser.JSON;
onEvent: function (e: Event) {
if (e.type==PullParser.INTEGER and e.name.equals("freeMemory")) {
freeMemoryValueLabel.text = Integer.toString(e.integerValue);
}
if (e.type==PullParser.INTEGER and e.name.equals("maxMemory")) {
maxMemoryValueLabel.text = Integer.toString(e.integerValue);
}
if (e.type==PullParser.TEXT and e.name.equals("serverName")) {
serverNameValueLabel.text = e.text;
}
if (e.type==PullParser.INTEGER and e.name.equals("threadCount")) {
threadCountValueLabel.text = Integer.toString(e.integerValue);
}
if (e.type==PullParser.INTEGER and e.name.equals("totalMemory")) {
totalMemoryValueLabel.text = Integer.toString(e.integerValue);
}
}
}

Silverlight application


A brief description of the technology. Silverlight provides a graphical system similar to the Windows Presentation Foundation , and combines multimedia, graphics, animation, and interactivity in a single software platform. It was created to work with XAML and with Microsoft .NET languages. XAML is used for layout pages with vector graphics and animation. The platform includes a browser plugin that allows you to run applications containing animation, vector graphics and audio-video clips, which is typical for RIA.
Benefits

disadvantages

Application code snippet
void refreshStatistics(object o, EventArgs sender)
{
WebClient proxy = new WebClient();
proxy.OpenReadCompleted += new OpenReadCompletedEventHandler(proxy_OpenReadCompleted);
proxy.OpenReadAsync(new Uri(uri));
}

void proxy_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
JsonObject jsObject = (JsonObject)JsonObject.Load(e.Result);
serverNameValueLabel.Text = jsObject["serverName"];
totalMemoryValueLabel.Text = jsObject["totalMemory"].ToString();
freeMemoryValueLabel.Text = jsObject["freeMemory"].ToString();
maxMemoryValueLabel.Text = jsObject["maxMemory"].ToString();
threadCountValueLabel.Text = jsObject["threadCount"].ToString();
}

findings


Conclusions about the comparison of modern RIA technologies and the results of the experiment on writing applications are presented in Table 2. Further, the comparison for each parameter is described in more detail.
Platform

Gwt

Flex / AIR
Javafx

Java applets

Silverlight

Developer

Google Inc.

Adobe Inc.

Sun
Microsystems

Sun
Microsystems

Microsoft

Creation language
applications

Java

Actionscript

Javafx script

Java

C ++,
C # Visual Basic,

Object Pascal and many
other

Support
by browser
customer

100% with the included
Javascript

~ 97-98% of browsers

~ 70% of browsers

~ 70% of browsers

~ 50% of browsers

Study time
for beginner
3-6 hours
3-6 hours
3-6 hours
3-6 hours
3-6 hours
Time on
the development of a demonstration
of the application
~ 1h
~ 2 hours
~ 3 hours
~ 1h
~ 3 hours
License

Apache
License
2.0
Mozilla public
License / Adobe
AIR user-
agreement
Javafx user-
soe
agreement
SUN / ORACLE
user-
agreement
Microsoft user
soe
agreement
Facilities
development
Eclipse
(is free),
NetBeans (free)
Adobe Flex (commercial
cue
product)
Eclipse
(is free),
NetBeans (free)
Eclipse (free
but),
NetBeans (free)
Microsoft Web Developer
Studio (free)
but)
Creature
interface in a graphical editor
development tools
Yes (with
the presence of
commercial
chesky
plug)
Yes
Not
Yes
Yes

Table 2 - Comparison of RIA technologies
Studying time for a beginner. A beginner in this case is considered a mid-level programmer who is not familiar with any of the technologies under consideration. According to the author, the writing of each application can take from three to six hours, if we consider the installation time of all necessary programs and reading the documentation.
Time to develop demo applications. The author of the article was familiar with the three technologies at the time of writing the applications, namely, GWT, Adobe Flex / AIR and Java Applets. So the maximum time for one program was 3 hours. Work with already known technologies lasted from one to two hours.
Browser client support. The fact that the client’s computer has the necessary platforms and extensions to launch the RIA can be judged by statistics from http://riastats.com . The audience reachers are GWT and Adobe Flex / AIR. This is due to the fact that in the first case no additional programs are required to be installed, and in the second, the widespread use of the Adobe Flash player on the computers of Internet users affects.
This is followed by JavaFX and Java Applets technology, covering approximately 70% of users. The main condition for their work is the presence of an installed JRE on a PC. Libraries for JavaFX have been included in it since version 1.5, and applet support has been around for a long time. With Java technology, Applets had no problems running in the browser. In the case of JavaFX, the author never managed to do this and the application runs only in windowed mode. Perhaps this is due to a recent JavaFX update, when applications stopped running in the latest versions of Opera and Firefox browsers.
Licensing and entry costs for developers.
  1. GWT is released under the Apache License 2.0. It gives the user the right to use the software for any purpose, freely distribute, modify, and distribute the modified copies. GWT can be downloaded for free from the developer’s website. Products written using GWT may have any license.
  2. Adobe Flex / AIR. The Flex SDK is available under the Mozilla Public License, and the Adobe AIR SDK is available under a user agreement with Adobe. Both products can be downloaded free of charge from the developer’s website. RIAs written using the Flex SDK and the AIR SDK may be released under any license.
  3. The JavaFX SDK is distributed under a user agreement with SUN / ORACLE. The license does not impose special restrictions on the distribution of JavaFX-based applications and they may be commercial ones as well.
  4. Java Applets. Components for Java Java Applets are part of the JRE library. They are available under a user agreement with SUN / ORACLE. JRE can be downloaded free of charge from the manufacturer’s website.
  5. Microsoft Silverlight is released under a user agreement with Microsoft. It does not impose special restrictions on programs written using the Silverlight SDK. The SDK is free to download from the Microsoft website.

Features of the organization of client-server interaction
The task of obtaining server load statistics in general consists of two stages. First, the implementation of the HTTP request to the server, and secondly, receiving data from the server response. For all examples, two objects are responsible for these actions in the application. The first one performs an HTTP request and, in the event of receiving a response, sends data to the second object. Next, it extracts the statistics data from the response and the user interface is updated.
The components responsible for implementing the HTTP request are included in the standard SDK library of each technology. However, with components that extract statistics data from a JSON response, the situation is different. If GWT, JavaFX and Silverlight are included in the SDK, then Flex / AIR also uses the JSwoof library ( www.waynemike.co.uk/jswoof ) for working with JSON, and for Java applets, the org.json package ( http : //json.org ) for Java.
Client-server interaction code can be compared by the number of lines. The results are in table 3:
Platform

Gwt

Flex / AIR
Javafx

Java applets

Silverlight
Number of lines
code for client-server organization
interactions
~ 40
~ 30
~ 30
~ 20
~ 30

Table 3 - Comparison of the number of lines of code for the organization of client-server interaction
The presence of the necessary components in libraries.
To write demo applications, two types of components were required:

Table 4 discusses the availability of the necessary components in the standard SDK.
Technology
Availability
visual components
Availability
client-server components
interactions
Gwt

Yes
Yes
Flex / AIR
Yes
Additionally
used JSWoof to work with JSON
Javafx

Yes
Yes
Java applets

Yes
Additionally
org.json package used to work with
Json
Silverlight

Yes
Yes

Table 4 - Using SDK components
In the case of Flex / AIR and Java applets, additional libraries were used to create the example, which are not included in the standard SDK.
The way to describe the user interface
To describe the technology interfaces, use 2 approaches:

The approaches used in Silverlight, Adobe Flex / AIR, and JavaFX make it possible to separate the interface description and the application code. In this direction, the latest version of GWT offers the UIBind tool for organizing collaboration between HTML designers and programmers. The source code can include files with HTML-code, which are embedded elements of the user interface. At the compilation stage, they will be associated with the program code. This allows you to work separately on the design in HTML.
Technical documentation and developer community. Information resources on each technology can be divided into three categories:

GWT:

Adobe Flex / AIR

JavaFX:

Java Applets:

Silverlight


The interest of developers in a particular technology, and therefore the creation of communities can be indirectly judged by the number of projects, for example, in the Google Code catalog (http://code.google.com). On the other hand, an important role is played by the number of job offers for each technology (website indeed.com ). The data are presented in table 5 and figure 2:
Platform

Gwt

Flex / AIR
Javafx

Java applets

Silverlight
amount
projects in the Google Code directory
1475
2388/703
119
166
180

image
Figure 2 - Number of RIA developer jobs
The choice of technology, the most suitable for solving the problem
According to the author, it is impossible to say that some of the technologies is a priority for solving the problem. The fact is that in the initial conditions there were no restrictions on the software of client computers, special modes of operation, etc. As for the task, it can be successfully solved with the help of each technology with the same success. This can be judged by written demo applications.
Source code can be downloaded here (project InelliJ IDEA 9)

Source: https://habr.com/ru/post/84320/


All Articles