The Pivot Framework has been raising eyebrows over the past few weeks. In short, it is an open-source framework for building high-quality, cross-platform applications that are easily deployable both via the web and to the desktop. It began as an R&D effort at VMware and is now being made available to the community as an option for developers who want to build rich client applications in Java. Its creators, Greg and Todd, have discussed the framework in various places, such as on Javalobby recently.
Elsewhere, articles have been written around what this framework aims to bring in relation to existing offerings. For example, on Ajaxian, the question of "what defines a Rich Internet Application (RIA)" is assessed. Though many developers associate animations and video with RIA, Greg and Todd argue that RIA "comes as much from the availability of more desktop-like functionality as it does from the media features". Delivering a comprehensive widget set was their primary focus for version 1 and they plan to come back and add support for effects and transitions in a later release. Furthermore, they'd also like to take advantage of some of the work that has been done for JavaFX in this area. With this background, let's explore Pivot, guided by Greg and Todd themselves.
Could you start by saying who you are and what you do?
Todd. My name is Todd Volkert; I'm a senior UI developer at VMware, Inc.
Greg. Greg Brown, Senior developer on the UI team at VMware.
What's Pivot about, in a nutshell, i.e., what's the specific problem it tries to solve?
Greg. Really immersive "desktop-like" UIs are simply difficult to build on the web. HTML was never meant to be a GUI platform. Users have much higher expectations for web applications now than they did 10 years ago. There is a limit to how far HTML can be pushed, and I think we're getting close to it. This is why we're seeing tools like Flex and Silverlight beginning to gain traction; however, both of these require developers who are otherwise happy using Java to switch technologies. Pivot is an attempt to create a modern, rich client development platform in Java.
Todd. The web development community has been trying to solve this problem for over 10 years. Pivot is an attempt to create a best-of-breed solution from which the entire UI development community can benefit.
the Pivot tutorial, showcasing a number of Pivot widgets
Has this problem been solved in other projects, if so, how, and how does Pivot compare?
Greg. Swing is an obvious comparison. In fact, Pivot takes a number of design cues from Swing. However, Swing is 10 years old, and it hasn't significantly evolved in that time. It just isn't quite as nice or as easy to use as some of the newer toolkits. We think Pivot offers a number of advantages over Swing:
- UI construction via XML markup, including CSS-like styling—This is a feature developers have come to expect thanks largely to HTML. Flex supports it, as does Silverlight. Swing doesn't, and this makes building Swing applications much more cumbersome.
- Constrained preferred size—Swing components can provide a preferred size to assist in layout. However, this size is "atomic" - one dimension cannot vary based on the other. Pivot supports the notion of "constrained preferred size"—the Component class defines getPreferredWidth(int height) and getPreferredHeight(int width) methods in addition to getPreferredSize(); passing a value of -1 to either of these methods indicates no constraint, but any other value tells the component to return its preferred size given this constraint. This allows us to wrap text in labels, for example.
- Common data model—All data-driven components use the interfaces in the pivot.collections package for model data. There isn't a separate TreeModel, TableModel, etc. This approach is analogous to Swing using the classes in for model data (though this isn't really possible since those classes don't fire events). The benefit is that any data that can be modeled as a collection is instantly available as a data model for a Pivot component. For example, Pivot includes a JSON serializer that deserializes JSON-encoded data into Pivot collections. This data can immediately be applied as a data model without any intermediary translation to the component's "native" data model, resulting in better application performance. The same applies to XML, CSV, or any other data you might want to read from a server. For example, Pivot includ
- Data binding—This is another fairly common feature in newer UI toolkits. If it's not done right, it can become more of a nuisance than anything else, but we think that the approach we have taken in Pivot will work well for a lot of developers.
We've also been asked, "what about SWT?" SWT is a very well-designed toolkit, but the SWT and Pivot philosophies are quite different. SWT attempts to be (and succeeds at being) a very thin layer over the native windowing toolkit. An SWT app on Windows looks like a Windows app—on Linux, it looks like a Linux app, etc. Pivot has a cross-platform look and feel: a Pivot application (intentionally) looks the same whether it is running on Windows, Linux, or Mac OSX. There are arguments to be made in favor of both approaches, and scenarios where one is more applicable than the other.
However, a bigger issue is that, to our knowledge, SWT is still not web-deployable. In other words, I can't write an "SWT applet". Pivot applications can be run within the browser as well as offline.
Todd. Other recent projects such as Adobe Flex, Microsoft Silverlight, and GWT (the Google Widget Toolkit) have also attempted to address the problem of web usability, but they all have some limitation that makes them unattractive for one reason or another. Pivot's main advantages over these platforms are:
- Pivot is open-source—Flex and Silverlight are not. (Correction from Todd: A reader correctly points out that Flex is open source -- Adobe announced their plans to open source Flex after we started development, and we unfortunately didn't keep up to date on its open source status.)
- Pivot is cross-platform; Silverlight may or may not be, depending on how well Microsoft ultimately supports it.
- Pivot applications are written in Java, a true object-oriented, compiled programming language—Flex applications are written in ActionScript, an ECMAScript variant.
- Pivot visuals are rendered in Java2D, a modern, vector-based graphics library—GWT rendering is limited to CSS and the DOM.
- Pivot applications may be multi-threaded to improve performance—GWT and Flex applications are always single-threaded.
- Pivot supports an XML-based markup language that simplifies UI construction—GWT does not.