Printer Friendly Version      Send     
Click to Rate and Give Feedback
Related Articles
We introduce you to the benefits of building composite applications with the Composite Application Guidance for WPF from Microsoft patterns & practices.

By Glenn Block (September 2008)
See how routed events and routed commands in Windows Presentation Foundation form the basis for communication between the parts of your UI.

By Brian Noyes (September 2008)
Windows Presentation Foundation dependency properties don’t always play well with others. Learn how you can compensate for their lack of notification events.

By Charles Petzold (September 2008)
We introduce you to the EDI functionality within BizTalk Server 2006 R2, illustrating schema creation, document mapping, EDI delivery and transmission, and exception handling.

By Mark Beckner (August 2008)
More ...
Articles by this Author
Windows Presentation Foundation dependency properties don’t always play well with others. Learn how you can compensate for their lack of notification events.

By Charles Petzold (September 2008)
Charles Petzold takes an inside look at the flexible bitmap pixel formats offered by the retained-mode graphics features of Windows Presentation Foundation.

By Charles Petzold (June 2008)
The System.Windows.Shapes namespace is Charles Petzold's namespace of choice for rendering two-dimensional vector graphics in WPF. Here he explains why.

By Charles Petzold (March 2008)
Charles Petzold demonstrates how Windows Presentation Foundation (WPF) templates let you turn common controls into uncommon visual objects.

By Charles Petzold (January 2008)
This month Charles Petzold explores techniques for generating 3D text in Windows Presentation Foundation.

By Charles Petzold (October 2007)
Learn what the WPF Animation Classes can do, what they can't, and how to extend them.

By Charles Petzold (July 2007)
This month Charles Petzold focuses on a very important part of the Viewport3D assemblage—the MeshGeometry3D class that defines the geometry of a 3D object in Windows Communication Foundation.

By Charles Petzold (April 2007)
This month we welcome Charles Petzold to MSDN Magazine with his first column on building apps for Windows Vista and the .Microsoft NET Framework 3.0.

By Charles Petzold (January 2007)
More ...
Popular Articles
Learn how to create a workflow that uses InfoPath forms and other office documents for passing data to targeted activities and for use in Office documents.

By Rick Spiewak (June 2008)
Systems that handle failure without losing data are elusive. Learn how to achieve systems that are both scalable and robust.

By Udi Dahan (July 2008)
Performance problems can creep into your Web app as it scales up, and when they do, you need to find the causes and the best strategies to address them.

By Richard Campbell and Kent Alstad (April 2008)
See how routed events and routed commands in Windows Presentation Foundation form the basis for communication between the parts of your UI.

By Brian Noyes (September 2008)
More ...
Read the Blog
SQL Server 2008 supports a new data type, HierarchyID, that helps solve some of the problems in modeling and querying hier­archical information. In the September 2008 issue of MSDN Magazine, Kent Tegels introduces you to the ...
Read more!
Many people using SharePoint technologies don't realize that there is auditing support built directly into the Windows SharePoint Services (WSS) 3.0 platform. In the September 2008 issue of MSDN Magazine, Ted Pattison walks you through a ...
Read more!
The September 2008 issue of MSDN Magazine is now available online. Here's what's in the issue: Hierarchy ID: Model ...
Read more!
Silverlight 2 features a rich and robust control model that is the basis for the controls included in the platform and for third-party control packages. You can also use this control model to build controls of your own. In the August 2008 issue of MSDN Magazine, Jeff Prosise describes how to ...
Read more!
In the August 2008 issue of MSDN Magazine, Matt Milner covers several topics regarding development with Windows Workflow Foundation, some that are intended to address specific reader questions, such as how to safely share a persistence database ...
Read more!
LINQ is a powerful tool enabling quick filtering data based on a standard query language. It can tear through a structured set of data using a simple and straightforward syntax. In the August 2008 issue of MSDN Magazine, Jared Parsons demonstrates a ...
Read more!
More ...
{End Bracket}
Let My People Code
Charles Petzold


In the 1920s, Hollywood was in trouble. Plagued by scandals and a general perception that the movies had gone too far in portraying sex and violence, there was a distinct danger that the government might step in. The studios responded by creating the Hays Office to police themselves and clean up the silver screen. The Hays Office established rules involving everything from proper language to appropriate displays of affection, and became the main arm of non-governmental censorship of the movies.
Movie writers and directors responded in the mid-1930s by finding creative ways around these restrictions. One such workaround was a new genre called the screwball comedy, which featured romance, slapstick, and wisecracks. There was little danger of lewd kissing in the screwball comedy-the romantic leads were often at odds for much of the movie. Even better, the dialogue was so fast and so hip that the censors couldn't even hear it. The result: classics such as It Happened One Night, Twentieth Century, and Bringing Up Baby-movies that would never have been conceived if writers and directors were free to do whatever their filthy minds desired.
Creativity often blossoms not when there is total freedom, but when severe restrictions limit the creator. Engineers as well as artists are familiar with this concept. When an oxygen tank exploded in Apollo 13 on its way to the moon, great creativity and ingenuity were required to make fixes. The creativity arose directly from the limited materials at hand.
I was reminded of this paradox recently while enjoying some of the most challenging and amusing programming I've ever done-and I wasn't even using a proper programming language! Lately, I've been getting my programming kicks with XAML, the Extensible Application Markup Language that forms a significant part of the Microsoft® Windows® Presentation Foundation.
XAML can access powerful classes in the Windows Presentation Foundation for performing layout and displaying graphics and animations. XAML can even be classified as a declarative programming language. But compared to more familiar programming languages, XAML is missing many basic programming features: There are no loops in XAML, no conditionals, and no way even to add or multiply numbers.
And yet, the more I restricted myself to XAML-only problem-solving-a state of existence I thought of as "living on Planet XAML"-the more creative I got. I realized that I could define composite graphics transforms in XAML that would essentially multiply matrices, thereby providing all the multiplication and addition I needed. And I found that I could simulate arrays in XAML by using a ListBox to hold multiple elements and then index those elements with data bindings.
My proudest achievement came with a XAML clock application. I wanted circular tick marks around the circumference of the clock. Customarily a clock has 12 large tick marks and 48 small tick marks, but without a for loop these tick marks would normally require 60 separate XAML elements. Alas, I just couldn't bring myself to create that much repetitive markup. I moaned over this problem for days until the breakthrough came. I could create precisely the tick marks I wanted by drawing two circles using dotted lines. Not only did it work, but I realized that I had done the job with just two graphics objects rather than the sixty most other clock applications required.
Writing XAML is fun. Writing XAML is challenging. Writing XAML is mind-expanding. But in some people's minds, writing XAML is an aberration. XAML is not supposed to be hand-written. As one Microsoft blogger put it, "XAML is for Tools," and over the months prior to its release, some XAML features have been removed because they were strictly for the benefits of humans rather than tools. Of course, XAML-generating tools such as Visual Studio® and Microsoft Expression® Interactive Designer may stimulate our aesthetic creativity, but they do nothing for our coding creativity.
Will future programmers even bother to learn XAML syntax? Or will they treat it as just "some weird XML stuff" that Visual Studio generates to save the layout of buttons and comboboxes?
Interactive designers and code generators certainly have their place in the modern programmer's arsenal. I'm sure they save lots of time. But let's not forget who we are. We are programmers. We are skilled in the art of writing powerful code. We get our kicks from using minimum code for maximum effect. We can make languages like XAML do things it was never intended to do. We can make it sing.


Charles Petzold is a contributing editor to MSDN Magazine and the author of Applications = Code + Markup: A Guide to the Microsoft Windows Presentation Foundation (Microsoft Press, 2006).

© 2008 Microsoft Corporation and CMP Media, LLC. All rights reserved; reproduction in part or in whole without permission is prohibited.
Page view tracker