Mozilla: a development platform under the hood of your browser

Should Java programmers migrate to it?

Download the whole article as PDF

Short URL: http://fsmsh.com/1215

Write a full post in response to this!


This article compares two development platforms: Java and Mozilla. The object of this comparison is not to establish which one is best, but rather to measure the maturity, the advantages, and the disadvantages of Mozilla as a platform from the point of view of a Java programmer (as I am). Such a comparison is not a speculative exercise but it is the result of a process of technology scouting that I have performed during the last months with the objective being to find more effective tools, languages, and patterns for the development of distributed, pervasive, and location-aware internet applications. The article briefly introduces Java and Mozilla, and then points to similarities and differences. A detailed analysis of some important programming domains such as GUI, multitasking, remote applications, community process, and development tools are presented together with a comparison of functionalities provided by the respective API.

A short introduction to Java

Java is a multi-platform object-oriented language. In other words, you can use constructs and patterns of object-oriented world to write programs deployable in different operating systems without changing a line of code and without “recompiling”. Although this is quite common for interpreted languages, the Java code is not interpreted. Java compilers build binary code called bytecode, which is loaded and executed by a virtual machine, independently upon which the operating system is running in the “real” machine. Thus, a bytecode compiled under Windows can be loaded and executed by a virtual machine running on Unix. The Java virtual machine hides underlying system-related details and it is provided with a unified API, common to all platforms. This implies that only the functionalities that are common to all platforms can be exploited by Java programs. The idea of “virtual machines” is not a new one; older languages such as Smalltalk introduced this solution years before Java, but as often occurs, the best and the first are not automatically the most successful.

If the portability of bytecode is one of the key features of Java, another important feature is that at the beginning of its life Java was considered the “language for the web”. This was due to Applets—programs that can be downloaded and executed inside a web page. Since its birth, both of these features of Java have revealed their limits. On one hand, bytecode portability assumes that the footprint of different machines is equivalent: loading bytecode compiled for a desktop PC in a PDA or to a cellular phone is in general not possible. On the other hand, Java Applets have gained less success and diffusion than other competitor technologies such as Macromedia Flash. Nevertheless, Java has gained a huge popularity among research teams and also for proprietary software. Among the most noticeable applications are the tools for Java programming written in Java. Moreover, to extend the adoption of Java in small footprint devices, different “editions” of the Java platform were created: J2SE is the Java 2 standard edition virtual machine for the desktop computing and personal system applications; J2EE is the enterprise edition which comprises server side components such as Servlet and Enterprise Javabeans. The J2ME profile aims at small devices such as mobile phones and embedded systems. For a complete classification of Java virtual machines and API please refer to Java’s web site [1]. In the domain of web applications, even though Java applets lost the war against Flash on the client side, things evolved favourably to Java technology on server-side. The J2EE provides a robust framework for secure and scalable applications competing with the ASP and PHP technologies.

One of the success points of Java is its technology pervasiveness. Java programmers “make themselves at home” in a vast range of domains: they can write stand-alone programs, application plug-ins, applets for web pages, web applications either in the form of servlets (Java code which embeds HTML tags) or Java Server Pages (HTML which embeds Java expressions), and Enterprise JavaBeans which build the application logic in multi-tiered architectures. Furthermore, Java scales the OOP paradigm to distributed systems by means of RMI (Remote Method Interface) and Jini (a framework which makes a deep use of code mobility to build dynamic collection of distributed services). In the domain of “small footprint” devices, Java has its JVM tailored for cell phones, PDAs, and smart cards.

One of the success points of Java is its technology pervasiveness. Java programmers “make themselves at home” in a vast range of domains

A short introduction to Mozilla

Mozilla is not a language. It is a known free software suite of internet clients. However, looking under the hood, you can discover that Mozilla is not only a browser and a messenger, but it is a platform with a complete component-based architecture. You can develop new stand-alone programs, add-ons for the browser, and code that can be loaded from remote hosts.

The Mozilla project has quietly become a key building block in the open source infrastructure. (Tim O’Reilly )

The most remarkable elements of the Mozilla platform are its component architecture called XPCOM (which recalls Microsoft COM) and the Gecko layout engine, which can render both HTML and the XUL mark-up language—an XML language for the definition of rich (as opposed to poor HTML forms) graphical user interfaces. The entire GUI of Mozilla is written in XUL and rendered by the HTML/XUL Gecko rendering engine.

The XUL approach has produced two main results: Firefox and Thunderbird. Aside from these two software masterpieces there are hundreds of small third-party add-ons, which cover any possible requirement of final users.

Firefox nudged IE below the 90 percent mark for the first time since the height of the browser wars in the 1990s. (Ina Fried and Paul Festa [3])

It is worth noting that Microsoft is likely to adopt a XUL-like solution for its Longhorn operating system. The Microsoft solution consists of an XML language called XAML for the definition of graphical user interfaces integrated by C# scripting [4].

Differently from Java, Mozilla does not define a unique programming language. According to its philosophy, Mozilla exploits the best (or the worst, depending on the point of view) of existing languages and adds its own dialects. XUL is not a programming language but rather a GUI description language; events in the GUI are handled by Javascript scripts which can connect to the XPCOM architecture using the XPConnect bridge. New XPCOM components can be developed in both C++ and Javascript and their interfaces are defined by means of XPIDL which is the Mozilla dialect for IDL (Interface Description Language). Data sources and configuration files are written in RDF. Finally, although XUL is used to define the structure of user interface, the final visual appearance is defined using CSS.

Mozilla implements W3C standards and its architecture reflects this acquaintance giving a running environment and a framework in which processing HTML, RDF, CSS and connecting to HTTP servers is almost a “primitive” functionality. On the other hand, Mozilla is mainly an internet-client platform and it does not pervade other domains. So the only possible comparison is with the Java Standard Edition in the domain of desktop applications.

Differently from Java, Mozilla does not define a unique programming language. According to its philosophy, Mozilla exploits the best (or the worst, depending on the point of view) of existing languages and adds its own dialects

Similarities

Classes are a central concept in Java. Any Java project is a set of classes (and other files like properties and resources), and even the entry point of a standalone program is a class containing a method called main().

Don't miss out on the other pages!
1234next ›last »

Write a full post in response to this!

0

Do you like this post?
Vote for it!

Copyright information

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is available at http://www.gnu.org/copyleft/fdl.html.

Biography

Davide Carboni: Davide Carboni holds a PhD in Computer Science. He is currently employed as "senior software engineer” at the Center for Advanced Studies, Research and Development in Sardinia (CRS4). His research interests are in the field of peer-to-peer systems, distributed computing, web applications, and agile software engineering. He runs his blog in http://powerjibe.blogspot.com

admin's picture

Comments from the old system

Submitted by admin on Thu, 2006-03-30 13:08.

Vote!
0

From: Rick S
Url:
Date: 2005-12-27
Subject: A couple of thoughts...

(1) IIRC, I read elsewhere that Mobile Device programmers are recently tending to move towards lower-level-language (C, C++) toolkits for their machines. These toolkits are becoming very feature-complete and easy to use (== faster, cheaper S/W Development). By eliminating the JVM and the "fat" bytecode, they get better performance... which generally means that they can provide more features, or run on cheaper hardware. (step= 1 Less memory; step 2= slower CPU; Step 3= more "Profit!!!", and reduced hardware also helps battery life).

(2) It ain't gonna be mobile, but GTK+ provides a very broad set of GUI tools- and the code is fast, small, and visually clean. We're both aware of how, even with code generators, the enormous number of lines which Java needs to implement 'listeners' and other necessary makes it intimidating and slow to work with. But on the other hand-- (a) Java doesn't let you make and use invalid pointers; (b) Java is much more portable, if you can afford the performance hit [e.g., GTK+ doesn't run on Windows '98].

(3) Kinda interesting: AFAIK, Seamonkey/Firefox uses the GTK+ "File Chooser" in it's "Open File..." and Directory selection dialogues, at least on Linux. They originally had their own GUI for this, but abandoned it a few years back. Simply passing through everything, invoking the GTK+ modal dialog (and Window) to do this work eliminated considerable headaches from maintaining the home-brewed XUL/XPCOM implementation.

One possible conclusion: If you're doing a GUI element which XUL/XPCOM doesn't already provide and GTK+ does (such as local filesystem browser), go directly to GTK+ (or an equivalent toolkit) via it's API.

From: Clemens
Url:
Date: 2006-01-03
Subject: Too much tech focus

Excellent article from a tech perspective but totally lacking the most important part - deployment and delivery. I love XUL as a developer but its pretty much worthless for anything mainstream because of the poor market penetration of Mozilla.

We can continue dreaming though ;-)



Two fantastic free software companies that make Free Software Magazine possible:

Other sites

Odiogo