Overview of current 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 that do not differ in appearance and behavior from desktop applications. This type of software 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 (the end of the 90s), they were widely used no more than 3-4 years ago.
    Talk about the features of RIA should start with a conceptual difference from HTML-based applications. Ordinary site-services work on the principle of switching to another page via hyperlinks and sending the form to the server using a web browser. In other words, the work of such applications is concentrated around the 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 necessary, and not for each user action.
    3. The problem of launching the application when there is no network connection.

    What solution does the RIA concept offer? From an architectural point of view, she translates such programs into the category of applications with a thick client. All RIAs have a similar feature: the presence of an intermediate part, which is transmitted over the network to the client and is responsible for interacting with the server and displaying a user interface that is much superior to HTML counterparts. In Figure 1 you can see the principles of organizing user interactions 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 (a platform-independent environment for launching RIA applications). The intermediate part, downloaded from the network, accesses it to save and read information. From here it becomes possible to send and receive data from the server only as necessary, 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, the main distinguishing features of the RIA can be noted:
    • the client part of the application is downloaded to the user's computer, which is responsible for interacting with the server and has the ability to cache data and work without connecting to a network;
    • runs in a browser or as a windowed application and requires the installation of the RIA platform;

    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
    Release date

    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 - The most common RIA technologies.

    The choice of these products is due to the prevalence on the Internet and the presence of installed platforms for users to launch RIA. In the following sections of the article, compact applications will be created to demonstrate the main technical features of each technology. The task of the programs is to obtain a brief statistics of the application server load at certain time periods and display it to the user. In response to each request, the server sends the following data packed in JSON :
    • server domain name;
    • full capacity of allocated memory;
    • amount of free memory;
    • maximum memory capacity;
    • number of running threads.

    Thus, the client parts of the demo applications are different, and on the server side, the Java servlet serves their requests.

    GWT Application


    Brief description of the technology. The RIA developer creates the interface and logic of the Java program, and GWT compiles the source code into carefully optimized JavaScript. The script file connects to the web page and displays the application interface at boot time. At the same time, firstly, the problem of having a special plug-in for the browser is solved - in fact, in the case of GWT, Javascript must be enabled (all modern browsers support it). Secondly, GWT has a large library of components for creating full-fledged RIAs and their number is constantly growing, thanks to a large community of developers. Based on these components, you can make traditional window interfaces in the browser.
    Benefits:
    • Use smaller, more compact, cached Javascript code;
    • Automatically support browsers IE, Firefox, Mozilla, Safari and Opera;
    • The library includes tools for processing transition events according to the list of previously visited pages in browsers ("Back" button).

    In addition, while working in Java, you can use:
    • Debugging tools that allow you to track the values ​​of variables, work with breakpoints, etc .;
    • Automated unit tests (based on Junit , etc.) both in the program and in the browser;

    As for the contents of the libraries, the GWT includes:
    • Built-in user interface components that serve as cross-browser building blocks of the application;
    • Remote calling of program code helps with client-server interactions (RPC, AJAX);
    • Tools for integrating GWT code into existing JavaScript code;
    • Developer tools to simplify interaction with interface designers (UIBind).

    disadvantages
    • Mandatory knowledge of Java. Despite the huge popularity of this language in creating web applications, it will be extremely difficult for a beginner who does not know the basic principles of user interfaces Swing or AWT.
    • Cross-browser compatibility has its pitfalls. The user interface components that are part of the distribution are thoroughly tested and really work the same in all browsers. However, the community is releasing new components whose behavior in different environments should be treated with caution. The problem is the experience of the developer.
    • The speed of the GWT compiler. This is an executable class in the Java language that takes paths to the source as arguments. In a small project of the author, the compilation time reached 2 minutes. As an alternative to launching the application, you can use a special hosted mode when the project is not compiled, but launched by special means in the selected browser (GWT version 2.0). In addition, you can compile the project for only one browser, changing the configuration, which will reduce the build time.

    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


    Brief description of the technology. Adobe Flex is a set of utilities for developing RIAs on the Adobe Flash platform using the ActionScript 3 language. Flash provides many more features than you can get from HTML in terms of interactivity. Nevertheless, development on Flash is a very complex process for simple programmers. Flash is aimed more at designers. Flex removes this barrier by providing a software way to develop the 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 the client program.
    Benefits
    RIA applications created in Flex can run in a browser using Adobe Flash® Player software, or as a regular program if the OS has a cross-platform Adobe AIR ™ application. Thanks to this, Flex applications support working with many common types of browsers, as well as 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 at Adobe.com. Currently 99% PChave Flash Player 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
    • The ActionScript language was originally the scripting language for the Flash player, which has undergone changes in Actionscript 3. As an object-oriented language, it lacks a lot of features that Java or .NET developers take for granted.
    • The number of third-party libraries (in particular, open-source) is orders of magnitude less than in Java.
    • Although the Flex SDK is free, the main development environment of Flex Builder is a commercial product.

    Application Code Snippet
    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


    Brief description of the technology. A Java applet is a bytecode Java application. Java applets run in a web browser using the Java Virtual Machine (JVM), or in Sun's AppletViewer, a stand-alone 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 bytecode, such as Jython.
    Benefits
    • cross-platform;
    • the applet is supported by most browsers;
    • it is cached in most browsers, and therefore will load quickly when it returns to a web page;
    • the access level of the applet to client data is configured by the computer user;

    disadvantages
    • applet development requires a middle-level programmer to have knowledge of the Java language; you must have an understanding of the Swing or AWT libraries to create a user interface;
    • it requires the installation of a Java extension, which is not available by default in all browsers. Currently, the plugin is installed on 90% of client PCs;
    • to increase the security of the applet, access to the user system is limited: in particular, it does not have direct access to the client disk or clipboard;
    • some organizations only allow software installed by administrators. As a result, many users cannot see applets by default.
    • applets may require the use of a specific version of the JRE.

    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


    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 in graphics, multimedia websites, etc. JavaFX applications are created using a declarative programming languageJavaFX Script. To develop JavaFX Script applications, you need to download and install the JavaFX SDK. From code written in the JavaFX Script language, you can access any Java libraries. Therefore, the joint use of Java and JavaFX Script allows you to solve various problems, 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 the JavaFX Script language can run on computers with the installed Java runtime 1.5 or higher. The following operating systems are currently supported: Windows, Mac OS X, GNU / Linux, and Solaris.
    Benefits
    • The JavaFX Script language supports the use of Java libraries and allows you to get compact code.

    disadvantages
    • there is still a problem with running on client machines. JavaFX applets do not run in the Opera browser, it is still unclear what is happening with Linux systems. True, this situation is gradually improving - JavaFX 1.2, according to the creators, works on Ubuntu and OpenSolaris.

    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 App


    Brief description of the technology. Silverlight provides a graphics system similar to the Windows Presentation Foundation , and combines multimedia, graphics, animation and interactivity in one software platform. It was created to work with XAML and with Microsoft .NET languages. XAML is used to lay out pages with vector graphics and animations. The platform includes a browser plug-in that allows you to run applications containing animation, vector graphics and audio-video clips, which is typical for RIA.
    Benefits
    • Starting with version 2.0, the program logic can be described in any of the .NET languages, including dynamic programming languages ​​such as Iron Ruby and Iron Python;
    • The .NET platform is a powerful tool for developing business applications;
    • A large number of third-party components from Infragistics, Syncfusion, Telerik (commercial products);
    • A large community of .NET developers.

    disadvantages
    • Silverlight is implemented for Windows 2000, Windows XP, Windows Server 2003, Windows Vista, Windows 7, Mac OS X 10.4, Mac OS X 10.5 and Internet Explorer 6.0 / 7.0 / 8.0, Mozilla Firefox 1.5 / 2.0 / 3, Safari 3.1, Google Chrome 3.0 Support for Opera is also planned in the future. Existing extensions for browsers in other operating systems are still at a preliminary familiarization stage.

    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();
    }

    conclusions


    Conclusions about the comparison of modern RIA technologies and the results of the application writing experiment 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


    Application Creation Language


    Java

    Actionscript

    JavaFX Script

    Java

    C ++,
    C #, Visual Basic,

    Object Pascal and many
    more

    Client
    browser support


    100% with
    Javascript enabled

    ~ 97-98% of browsers

    ~ 70% of browsers

    ~ 70% of browsers

    ~ 50% of browsers

    Learning time
    for a beginner

    3-6 hours
    3-6 hours
    3-6 hours
    3-6 hours
    3-6 hours
    Time to
    develop a demo
    application

    ~ 1 hour
    ~ 2 hours
    ~ 3 hours
    ~ 1 hour
    ~ 3 hours
    License

    Apache
    License
    2.0
    Mozilla Public
    License / Adobe
    AIR
    Terms of Service
    JavaFX user-
    skoe
    agreement
    SUN / ORACLE Terms of
    Service

    Microsoft user-
    skoe
    agreement

    Development tools

    Eclipse
    (free),
    NetBeans (free)
    Adobe Flex (the Commercial
    cue
    product)
    Eclipse
    (free),
    NetBeans (free)
    Eclipse (free
    ),
    NetBeans (free)
    Microsoft Web Developer
    Studio (free
    )
    Creating an
    interface in a graphical editor of a
    development tool

    Yes (when
    available
    commercially
    Cesky
    plugin)
    Yes
    Not
    Yes
    Yes

    Table 2 - Comparison of RIA technologies
    . Study time for a beginner. A novice in this case is a mid-level programmer who is not familiar with any of the technologies in question. According to the author, writing each application can take from three to six hours, given the installation time of all the necessary programs and reading the documentation.
    Time to develop demo applications. The author of the article was familiar with three technologies at the time of writing 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.
    Client browser support.The fact that the client has the necessary platforms and extensions installed to run RIA can be judged by statistics from the site http://riastats.com . The leaders in reaching users 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 is reflected.
    This is followed by JavaFX and Java Applets technologies, covering approximately 70% of users. The main condition for their work is the presence of the installed JRE on the PC. Libraries for JavaFX have been included since version 1.5, and applet support has been around for a long time. There was no problem with Java Applets technology when launched in a browser. In the case of JavaFX, the author was not able to do this and the application runs only in windowed mode. Perhaps this is due to a recent update to JavaFX, when applications stopped running in the latest 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, to freely distribute, modify, and distribute modified copies. GWT can be downloaded for free from the developer's site. Products written using GWT can be licensed in any way.
    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 for free from the developer's site. RIAs written using the Flex SDK and AIR SDK can be released under any license.
    3. The JavaFX SDK is distributed as part of a user agreement with SUN / ORACLE. The license does not impose any special restrictions on the distribution of JavaFX-based applications, and they may also be commercial.
    4. Java Applets. Components for Java Applets are part of the JRE library. They are available as part of a user agreement with SUN / ORACLE. JRE can be downloaded free of charge from the manufacturer's website.
    5. Microsoft Silverlight is released as part of 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 Microsoft.

    Features of the organization of client-server interaction
    The task of obtaining server load statistics in the general case consists of two stages. Firstly, making an HTTP request to the server, and secondly, receiving data from the server’s response. For all examples, two objects are responsible for these actions in the application. The first makes an HTTP request and, if a response is received, passes data to the second object. He then extracts the statistics from the response and the user interface is updated.
    The components responsible for the implementation of the HTTP request are included in the standard SDK library of each technology. However, things are different with components that extract statistics from a JSON response. If GWT, JavaFX and Silverlight have them 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
    The number of lines of
    code for organizing client-server
    interaction
    ~ 40
    ~ 30
    ~ 30
    ~ 20
    ~ 30

    Table 3 - Comparison of the number of lines of code for organizing client-server interaction
    The presence of the necessary components in the libraries.
    Two types of components were required to write demo applications:
    • visual elements of the user interface;
    • non-visual components for organizing client-server interaction.

    Table 4 discusses the presence of the necessary components in the standard SDK.
    Technology
    The presence of
    visual components

    Availability
    of client-server
    interaction components

    Gwt

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

    Yes
    Yes
    Java applets

    Yes
    Additionally
    used org.json package for working with
    JSON
    Silverlight

    Yes
    Yes

    Table 4 - Using the SDK components
    In the case of Flex / AIR and Java applets, additional libraries are used to create the example, which are not part of the standard SDKs.
    The way to describe the user interface
    To describe the interfaces of the technology, 2 approaches are used:
    • с помощью языка программирования(GWT, Java Applets). В этом случае все компоненты описаны в файле с исходным текстом в виде переменных. На этапе запуска приложения они инициализируются в коде и располагаются в окне приложения.
    • декларативным методом, средствами специального языка на основе XML(XAML для Silverlight и MXML для Adobe Flex/AIR) и с помощью JavaFX Script. В исходном тексте соблюдается вложенность компонентов для их последующего расположения на экране. Для Silverlight и Adobe Flex/AIR характерно то, что исходный текст программы и XML-описание интерфейса могут храниться в одном файле.

    The approaches used in Silverlight, Adobe Flex / AIR and JavaFX allow you to separate the description of the interface and the program code of the application. 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 into which user interface elements are embedded. At the compilation stage, they will be associated with the program code. This allows you to separately work on the design in HTML.
    Technical documentation and developer community. Information resources devoted to each of the technologies can be divided into three categories:
    • official technical documentation on the developer's website;
    • articles with examples of the use of technology found on blogs and other information resources;
    • Forums dedicated to a particular technology.

    GWT:

    Adobe Flex / AIR

    JavaFX:
    • javafx.com is the official site of technology developers, useful in that it has links to JavaFX community resources on documentation and sample programs.
    • blogs.sun.com/javafx is a JavaFX blog.

    Java Applets:
    • java.sun.com/applets - A page on the SUN / ORACLE website dedicated to Java Applets technology. There is technical documentation and sample applications, as well as links to forums and other resources.

    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 directory (http://code.google.com). On the other hand, an important role is played by the number of job offers for each technology ( indeed.com site ). The data are presented in table 5 and figure 2:
    Platform

    Gwt

    Flex / AIR
    Javafx

    Java applets

    Silverlight
    The number of
    projects in the Google Code directory
    1475
    2388/703
    119
    166
    180

    image
    Figure 2 - The number of vacancies for RIA developers.
    Choosing the technology that is most suitable for solving the problem.
    According to the author, one cannot say that some of the technologies is a priority for solving the task. The fact is that in the initial conditions, restrictions on the software of client computers, special modes of operation, etc. were not specified. As for the task, it can be successfully solved using each of the technologies with equal success. This can be judged by the written demo applications. Sources
    can be downloaded here (InelliJ IDEA 9 project)

    Also popular now: