If you'd rather listen to this month's column as a podcast, you can download it here.
The "Silverlight/ WPF thing" has dominated some serious Internet fodder for years now. The rumors of both of their deaths and their dominance at the expense of each other have been speculated so many times before incorrectly that I believe it is best to regroup. So with this month's column, I will attempt to clarify where you'd use Silverlight and where you'd use Windows Presentation Foundation (WPF).
But first, let me start with defining just what both WPF and Silverlight are. Defining each of them, Silverlight and WPF, will help to clarify the contrast between them. And will help to clarify the roadmap for both of these technologies in the .NET stack.
First, here's what WPF and Silverlight are:
- They are both .NET; just as much as ASP.NET is .NET, both WPF and Silverlight are part of the .NET stack.
- They are both XAML based. XAML, short for Extensible Application Markup Language, is an XLM-like, tag-based language used to define user interfaces. XAML is declarative like HTML. Ultimately for the .NET developer, XAML is nothing more than a way to initialize and construct .NET objects. That .NET object might be a simple button on a form or some other sophisticated part of the user interface.
OK, now I'll try to define WPF—because WPF came first. WPF's code name was "Avalon," and it was initially released as part of .NET Framework 3.0, officially shipping in Windows Vista in November 2006. But what you might not know is that the Avalon was started back in 2001, even before .NET Framework 1.0 was released—from the team that originally developed Internet Explorer 4 DHTML support and the XMLHttpRequest API that enables AJAX. There is an awesome video interview on MSDN's Channel 9 site of Michael Wallent—the GM of the Microsoft Avalon Team and one of the original architects of WPF and Silverlight. When you are done reading my column and want to dive deeper into the WPF/Silverlight thing, I strongly encourage you to watch that 45-minute interview. In my opinion, it is the most interesting video interview on the entire MSDN site.
The Essence of WPF
OK, so WPF has been around a long time. But—what is it? Well, WPF is a .NET based graphical subsystem for rendering user interfaces in Windows-based applications. "Windows applications" is the key here. WPF is not cross platform; it only natively runs in Windows.
Microsoft has released four major versions of WPF to date: WPF 3.0 (November 2006), WPF 3.5 (November 2007), WPF 3.5 SP1 (August 2008), and WPF 4 (April 2010).
Now many people get confused about WPF being cross platform because it runs on other devices like the Microsoft Surface. But, the Surface is nothing more than a Windows device; believe it or not, Windows Vista runs under the hood. And you will see WPF running on other devices coming from Microsoft in the immediate future. But ultimately, each of those are Windows devices.
OK, so WPF is Windows and its .NET and it's huge. In fact, as far as the surface of the API goes—meaning the amount of .NET Framework classes that exist for WPF, did you know that WPF is as big as Windows Forms and ASP.NET combined? It's huge. In that regard, it's much like the Win32 API, and that is why native programmers love WPF. It's rich, and it's elegant, and there's a way to do most everything, which for a framework like .NET is pretty impressive.
The Essence of Silverlight
So let's switch to Silverlight. Silverlight is a lightweight, cross-platform version of WPF. There are two keys here. The first is "lightweight." Silverlight's runtime packs into a small downloadable package that you acquire in the browser when you first touch a Silverlight site. Silverlight is 4.2mb, and there is a reason for that… because Flash, Silverlight's worthy competitor, is 4.2MB. Silverlight could easily be bigger, but 1) it has to compete with Flash and 2) no one on slow Internet connections wants to download anything huge in terms of runtimes just to use a website or application. So, Silverlight is just a tiny portion of WPF. Typically we say in WPF there are 10 ways to do everything, and that type of breadth makes it elegant—and in Silverlight you can do almost everything and there's only one way to do it, which makes Silverlight elegant in its simplicity.