Article
Introducing XUL - The 'Net's Biggest Secret: Part 1
Here's a question: what if I was to tell you that you can write your own version of Word using something like HTML and JavaScript? What if I added that you could run on your hard disk or launch it directly from your Web server and use it to update your site's content? It sounds a little far fetched, I know, but it's right here, right now -- and it calls itself "Zool".
Here’s what this three-part series will cover:
- The XUL Revolution: just who is Zool?
- Back to School: time to dust off that JavaScript...
- Zoolology: getting read to fire up your first XUL application
- 3D Browsing with XUL: straight in at the deep end.
- Desperately Seeking: the search is over.
- Takeaway Menu: with fries please!
- But no one uses Mozilla: back to browser detection.
- The Rise of the Rich Client: the future is XUL.
The XUL Revolution
In one of the Internet’s quieter corners, mozilla.org, a revolution has been taking place. A new XML format, called XUL (eXtensible User Interface Language), pronounced "Zool", is on the way to re-shaping what we know about both the Internet, and desktop applications. A bold claim perhaps -- but once you've finished reading this, you may just find yourself agreeing.
The conceptual leap that's taken place at Mozilla is to think beyond the Web browser as simply being a tool for viewing Web pages, and instead, to look at it as a framework -- a runtime environment for executing applications, just as you might run programs in the Java and .NET runtime environments.
While we were all watching .NET and Java fighting it for developer and corporate "mind share", Mozilla have quietly made their revolution happen with little hype or attention; right now, a Google search for “XUL” yields only 103,000 results, for example.
Of course, Open Source projects rarely have money to advertise, and Mozilla (well, Netscape in fact) have to overcome the additional stigma of being the project that "lost" the browser wars. But, if you take a look at XUL today, you’ll be surprised at how little is being said about it. Something tells me that the real fun is only just beginning...
What's fascinating about XUL and its sister technology, XPCom (Cross Platform Component Object Model), is that they have all the hallmarks of .NET and Java:
- a library of "widgets" for building applications (as with .NET WinForms and Java's Swing)
- separation of presentation logic from application logic, the presentation logic being handled by JavaScript
- support for XML messaging protocols like SOAP and XML-RPC
- support multiple languages for building "code behind" components including C++, Python and Ruby, with Perl in progress -- though, sadly, no PHP yet(!).
- truly cross platform; anywhere you can run Mozilla, you can run your XUL/XPCom applications.
But it doesn't stop there -- writing an application in XUL is like writing a Web page with DHTML, except that your XUL application will work, while your DHTML might.... XUL provides a markup that will be easy for anyone with HTML experience to pick up, and has all the advantages of a text-based markup language, such as being able to generate it "on the fly" with PHP.
Better yet, XUL allows for the use of existing technologies, such as CSS, to modify the look and feel of your XUL applications, and SVG, to add some visual flair. You can also mix HTML with XUL -- you can put together hybrid pages, to, for example, bring a boring HTML page to life with some XUL widgets. Don't expect to find XUL listed at w3.org, though -- this is entirely Mozilla's idea.
All you need in order to run XUL applications, is to have Mozilla installed, right? Well… almost. There are a number of projects that aim to bring XUL to other runtimes and environments, such as Mozilla's Blackwood Project, Luxor XUL, jXUL and XULUX, all of which bring XUL to Java in some manner. It's also possible to Embed Gecko, which could bring XUL to devices like mobile phones and PDAs.
Not that you need to worry about any of those today; all you need to run XUL applications is Mozilla (or a browser based on Mozilla such as a recent version of AOL or Netscape).
"All very good", you might say, "but this looks as if it’s just going to be another poorly implemented technology that will do nothing but waste my time."
Well how about this: ActiveState have already released Komodo, an IDE that was written using the Mozilla code base, and takes advantage of XUL. You'll find many smaller projects listed at mozdev.org. Anyone for a game of XULMine? You can run it right off site (you’ll need Mozilla installed, of course)! Notice how it looks like any other windowed application? And see how quickly it loads...?
Now that you have a rough idea of what XUL is about, it’s time to brush of those dusty "Best viewed with ..." signs from the last browser wars, and slap them back up on your Website. It's time to get busy with XUL...
Harry has been working in corporate IT since 1994, with everything from start-ups to Fortune 100 companies. Outside of office hours he runs