Silverlight, for real this time

Microsoft's RIA framework offers client-side programming with .Net languages and tools, plus high performance

Microsoft's answer to Adobe Flash and Flex and several other RIA (rich Internet application) and AJAX frameworks, Silverlight arrived with a flourish just over one year ago. Silverlight 1.0 manipulated its multimedia-savvy, WPF (Windows Presentation Foundation) user interface using JavaScript. Silverlight 1.1, which added support for compiled .Net languages and supported more of the .Net API, was available at that time only as an alpha test.

Silverlight 1.1 turned out to be such an important upgrade for Microsoft that it was eventually renumbered Silverlight 2. As delivered now, Silverlight 2 supports all .Net languages, including the dynamic languages such as IronPython and IronRuby, and it contains a good chunk of the .Net base classes, including newer features such as LINQ (language-integrated query). In addition to a rich set of controls with more on the way, it has APIs for an alphabet soup of networking, including REST, SOAP, RSS, and HTTP; includes local data caching and storage; and supports HD video among other rich media formats. H.264 video and AAC (Advanced Audio Coding) audio support is planned for Silverlight 3.

Poster-child Silverlight deployments such as the Beijing Olympics last August have been favorably reviewed and generally well received. There was of course the usual chorus from people with incompatible hardware and operating systems, but nothing unexpected. From Microsoft's viewpoint, at least, the Silverlight Internet video streaming of the Olympics provided by NBC in the US, China Central Television in China, and broadcasters in 10 other major national markets, was a huge success. More recently, Silverlight 2 enabled Blockbuster to offer high-quality streaming video to PC and Mac users of its MovieLink service.

Capabilities and controls

Silverlight 2 should eventually be good for any kind of RIA, given its strong language support and class library and good runtime performance, not just video streaming. Right now, it probably lacks a few user interface controls out of the box for some applications: There are only 28 items in the standard Silverlight Controls toolbox, and another 12 in the Silverlight Toolkit, with a plan for 100 controls total to be made available over the next months. It's not that hard to build new Silverlight controls, and many are already available from ISVs, but if you're not in a hurry, you may find that Microsoft eventually delivers all the controls you need.

Security in the face of cross-domain access is a potential issue for any browser-based application, whether or not it uses a plug-in such as Silverlight or Flash. Silverlight does have its own cross-domain security mechanism, controlled by a manifest file setting, which defaults to the most secure setting.

I have seen accusations online that the Silverlight local data storage might still be vulnerable to cross-domain attacks despite this mechanism, but I haven't been able to prove or disprove this. The same source claims that Flash local objects are open to the same kind of attack.

Page Break

Development and design

I tried Silverlight 2 development using Visual Studio 2008 SP1 and Expression Blend 2 SP1. I didn't have any trouble picking it up and developing with it, but I was already familiar with Visual Studio, C#, the .Net Framework, and XAML. Other programmers with backgrounds in .Net languages (now quite a large selection, including IronPython and IronRuby in addition to C#, Visual Basic .Net, JavaScript, and so on) and with XML-based markup (including MXML and even HTML) should find it easy to learn and develop for Silverlight.

The basic method for programming XAML elements is to give them a x:Name tag, for example:

Once the x:Name attribute has been set, the program can manipulate the properties of the element, very much in the same spirit as JavaScript manipulating HTML elements in DHTML:

message1.Text = "Hello, " + name1.Text;

This connection between program and XAML element by name is the key to using teams of programmers and designers to develop Silverlight and WPF applications. As long as the names don't change, the programmers can modify the code-behind files, and the designers can modify the XAML files without breaking the interface between the two. They might not even use the same tools.

As a programmer who also does a little design, I was disappointed to find that I could not drag controls onto the graphical pane in the Visual Studio XAML designer; that pane is only a preview, so I could drag controls only into the XAML text. On the other hand, XAML editing in Visual Studio is supported nicely by IntelliSense, and the instant-preview pane does help quite a bit when you're trying to get the appearance of a page just right.

Expression Blend provides a graphical design surface for XAML pages, but it doesn't offer much in the way of programming support. It would certainly be the Silverlight tool of choice for most designers. In an ideal world, I might wish for a unified tool that serves the needs of programmers and designers alike, but Visual Studio and Expression Blend integrate well enough, and they are probably better suited for their target audiences than a unified tool would be.

Page Break

Versus Flash and AJAX

The obvious comparisons for Silverlight are to other RIA technologies, the most prominent of which are AJAX, Adobe Flash, and Adobe Flex. One advantage of AJAX is that there is no permanent installation. Another is the wealth of AJAX toolkits, effects, and controls available. These are balanced by the tendency of AJAX applications to be dependent on browser implementations and the relatively primitive tools available for AJAX page design. There is also a performance issue: The typical browser's JavaScript interpreter is relatively slow.

Flash is aimed at designers rather than developers, while Flex is aimed at developers rather than designers. The two can be combined, however. Flash designers may find that Expression Blend meets their needs for Silverlight development, although many Flash designers tend to be fiercely loyal to their chosen technology. Flex programmers may find that writing Silverlight XAML with code-behinds in Visual Studio is very much in the same spirit as writing MXML with ActionScript in Flex Builder; again, they may not find much enthusiasm for making that transition unless they also work on .Net applications.

Never underestimate the conservatism of children or programmers.

In my own comparisons, Silverlight 2 outperformed any of the other RIA technologies mentioned here by a significant margin, exhibiting compute and display speeds similar to those of my previous favorite, Curl. I have also seen benchmarks that came out differently; it all depends on what you measure. It is possible to overload the Silverlight 2 rendering pipeline and slow it down on some hardware. XAML enables quite a few sophisticated graphics effects that require a good GPU to achieve decent rendering speed.

Much has been made of the large installed base of Flash plug-ins. In some ways, this isn't terribly important. Silverlight's download footprint is not so big as to present a barrier to first-time users, at least for broadband users. Nevertheless, I asked my friends at PC Pitstop to give me a comparison of Flash installations and Silverlight installations. In September, Flash was installed on more than 90 percent of the roughly 75,000 distinct computers that tested at the site, while Silverlight was installed on roughly 33 percent. It will be interesting to monitor the Silverlight 2 uptake over the next few months as more applications that use it are rolled out.

When Silverlight was introduced, some pundits thought it might be Microsoft's "Flash killer." I don't really think that's the case, for two reasons. One is that many organizations have an existing investment in Flash video servers. The second reason is that Flash and Flex designers and developers tend to be very comfortable with their tools and loyal to Adobe. They don't really care whether Microsoft has something better for them, because they're too busy chopping down trees to trade their axes for chainsaws, especially when they're good with their axes and haven't learned to use chainsaws.

Nevertheless, Silverlight has substantial technical merit and relatively good performance. It's a very capable RIA technology that's especially useful in the hands of programmers with .Net experience and designers with XAML experience.