It’s a WPF World, part 1

Has everyone realized that it’s a WPF world out there?  What I mean is this.  Let’s say you’re a classic Windows programmer–meaning that you want to build a basic native Windows application.  You know–just an .exe file that lives on your hard drive, that you run, and that displays a window with some stuff in it.   (Let’s set aside for just a moment Bill’s “Internet Tidal Wave” and Ozzie’s “Device Mesh” and assume that you want to build a good old-fashioned Windows app).  Where are we at today?  Well, WPF is absolutely the world that we live in at the moment.

Let’s think about how we got here.  In the beginning, it was a WinAPI world.  For years, the mantra was, “Thou shalt read Petzold, cover to cover”.  If you don’t know what this means, you’re either too young or you just plain don’t care about what’s under the hood.  With NT and Windows 95, we got to graduate to Win32, but it was still a grand world, working with WinAPI.  (Test yourself–do you get a warm fuzzy feeling, or do you shudder, when you read the following)?

SendMessage(hList,LVM_SETITEM,0,(LPARAM)&LvItem); // Enter text to SubItems

Ahh, memories. Well, after the WinAPI world, we got to graduate to the world of MFC.  (Didn’t it stand for “Millions of Freakin’ Classes”)?  Remember message maps and CCmdTarget?  Actually, aside from unwanted Afx functions in later COM applications and the inevitable bloat, I mostly escaped working with MFC.  I was writing Motif applications for VAX/VMS at the time–but that’s a different story.

Then we come to the glorious days when it was a COM world.  Ahh–David Chappell, Don Box, and even–shudder–Brockschmidt.  I’m still paying off loans taken out to buy tech books during the COM era.  All you really need to know about COM is: a) it’s all about interfaces, baby; b) you need to chant the following in your sleep every night–QueryInterface, AddRef, Release; and c) you’ll learn to love the venerable BSTR.  When I’d worked with COM long enough to finally understand it, my main thought was–holy crap, this stuff is complicated enough that I now truly have job security.

It was, briefly, an ATL world.  ATL was a fluffy breath of fresh air for the beleagured COM programmer.  Or maybe it just felt like a well-earned reward for having truly learned COM.  Sort of like the boy scout who finally gets to use a gas stove after years of making fires by rubbing two sticks together.  Actually, I get a pretty warm fuzzy feeling, remembering ATL–and building out-of-process COM servers in VC6.  Not a bad world at all, really.  I almost miss it.

Still with me as I ramble?  Shall we jump to 2002, when it became a .NET world?

Ok, a brief rant.  A few years back, a fellow colleague (Software Engineer), who’d been a developer for quite a few years, confided to me that he liked programming, but what he absolutely hated is how things kept changing.  Every time a new technology came out, he became infuriated.  I was a little shocked–first of all, because the constant stream of new technologies is what I absolutely love about being a Windows developer.  But mainly, I thought–if you hate change so much, why the hell are you a Windows developer?

On to 2002, when it became a .NET world.  Regardless of when you jumped into .NET, or which Windows technology you came from, you just have to agree that .NET is our Seventh Heaven reward for all of those years of wrestling with these other technologies.  Or is it just Dante’s outermost circle of hell?  In any case, being a C# developer in the .NET world is truly a treat, after the path that we’ve taken to get here.  (Yes, yes, yes–VB.NET is fine language, you do have XML literals while we do not, and you are a person that people like and respect).

If you can’t tell, I’m a C# developer.  Of course, as has been said many times before, the choice of language in .NET is really irrelevant–it’s all about the framework.  The learning curve is obviously in learning thousands of framework classes, rather than arguing about this vs. Me.  I’m definitely not a VB hater–I’ve written a lot of VB6 code over the years.  But I just love working with C#.  It’s C++ with all the dangerous pointy stuff that can hurt you removed.  So no need for political correctness here–I’m going to post examples in C# and get on with it.

What’s so special about .NET?  Some of the standouts for me, in no particular order, are:

  • Language Independence — you can write in your language of choice, since all CLS-compliant languages just resolve to IL and your code can run in the the CLR.
  • Memory Management — (and garbage collection).  No more having to remember to delete every element of an array, as well as the array itself.  Just create your objects and let the CLR worry about having to delete them.
  • CLR as a VM — because your code runs in a virtual machine, we can hypothetically run anywhere and are no longer tied to Windows.  (E.g. Mono).  This is less critical for thick clients but will become more important as we move to Silverlight 2).
  • Reflection — very cool, for debugging, discovery, or just the elegance of having an assembly be self-describing.  Much nicer than the old COM external .tlb file scheme.
  • The .NET Framework — without a doubt, the greatest benefit of .NET.  Wow–thousands of classes that someone else has written that just work.  I’m constantly stumbling on things that I thought I’d have to write, but discover are already present in the framework.

That’s a very crude list of some of the highlights of .NET and why I think it’s so powerful.  There’s no need for me to write yet another high-level overview of what .NET is, or what the parts are.  The book Understanding .NET, by David Chappell is still an excellent introduction/overview.

Well, I’ve run out of room and run out of time.  I’ll save the rest of this particular ramble for later, when I talk just a bit about Win Forms, ASP.NET, and WPF..

[Ok, an editorial comment–this started out being a simple set of notes for creating a first “Hello World” WPF application.  Instead, it sort of turned into a campy litany of old Microsoft technologies.  So I’ll save the Hello World post for next time].

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s