# Saturday, February 03, 2007

This year I will be partnering with my friend Tim Huckaby to deliver a pre-conference session at Tech Ed USA 2007 in Orlando:

PRCN12 From Design to Deployment: Everything You Need to Know to Optimize Your Applications for Windows Vista 
Kate Gregory and Tim Huckaby
Windows Vista is the most compelling operating system release in nearly a decade. With major improvements in the areas of security, user experience, and performance, Windows Vista offers a robust and dependable platform for building a breadth of solutions. This full day seminar prepares you for building a new class of applications that take advantage of these improvements. Come and see how to take advantage of some of the most interesting new native APIs, inter-op techniques, and .NET Framework 3.0 technologies.

In this all-day pre-conference seminar, learn how to build the next generation of smart client applications with the Windows Presentation Foundation (WPF). Learn the fundamentals of WPF and work your way through advanced topics like 3D. Learn how to build great user experiences with technologies like task-based dialogs, sidebar gadgets and customized Windows search functionality. Learn inter-operability techniques with managed wrappers and how to leverage the Vista Bridge. Dive into the best practices for upgrading existing applications, leveraging User Access Control (UAC) and techniques for virtualization. Learn how to build more reliable and secure applications with technologies like Windows Error Reporting, Next Generation Cryptography and Application Restart/Recovery. And lastly, learn how to build more connected systems with Windows Communication Foundation (WCF) and RSS platform support.

Many Tech Ed attendees come a day early to do a pre-con and jumpstart themselves to be ready for the rest of the conference. Registration is open and the early bird discount is still in effect.

Other RDs delivering pre-cons include Scott Hanselman, Richard Hundhausen, and Kimberly Tripp along with many other people you have heard of. This is great opportunity to get up to speed on a topic very quickly. You can then go and drill further into some niche of it that interested you, by attending breakouts on that subtopic.

See you there!

Kate

ps: do I have a breakout session? There's no announcement on that yet :-)

RD | Speaking | Vista
Saturday, February 03, 2007 12:26:20 PM (Eastern Standard Time, UTC-05:00)  #    
# Friday, February 02, 2007

It's easy to get intimidated by a feature like Lambda Expressions. It has a Greek word in it, so it must be difficult, right? And you can read explanations like this:

Lambda expressions, one of the most important new features to be included in the next 3.0 version of C# and one that offers support needed by the LINQ Project, are precisely a feature coming from the world of functional programming. ... Scheme ... Lisp ...

Or this summary:

In mathematical logic and computer science, lambda calculus, also λ-calculus, is a formal system designed to investigate function definition, function application, and recursion. It was introduced by Alonzo Church and Stephen Cole Kleene in the 1930s; Church used lambda calculus in 1936 to give a negative answer to the Entscheidungsproblem. Lambda calculus can be used to define what a computable function is. The question of whether two lambda calculus expressions are equivalent cannot be solved by a general algorithm. This was the first question, even before the halting problem, for which undecidability could be proved. Lambda calculus has greatly influenced functional programming languages, such as Lisp, ML and Haskell.

Lambda calculus can be called the smallest universal programming language. It consists of a single transformation rule (variable substitution) and a single function definition scheme. Lambda calculus is universal in the sense that any computable function can be expressed and evaluated using this formalism. It is thus equivalent to the Turing machine formalism. However, lambda calculus emphasizes the use of transformation rules, and does not care about the actual machine implementing them. It is an approach more related to software than to hardware.

This sounds really difficult. So let me show you something that's not difficult at all:

<input type=button value="Try it now" onClick="alert('Hello from JavaScript!')">

You know what that does, right? Well the stuff after onClick=" and before "> is [gasp!] a Lambda Expression. It's a little piece of code that you can stick somewhere without a whole lot of defining a function and defining a delegate and pointing that delegate at that function and blah blah blah. You can stick two lines of JavaScript in there if you want:

<INPUT TYPE="radio" VALUE="Switching to Blue" onClick="alert(value);document.bgColor='blue'">

This feels natural and ordinary in JavaScript, and all folks are talking about is giving you that same freedom in strongly typed languages where the compiler is your friend. We have some of this in C# 2.0 with anonymous methods, but lambda expressions are in effect more strongly typed. Here's a nice explanation of the subtle distinction.

It's not actually that intimidating at all ... it's going to make life easier.

Kate

Friday, February 02, 2007 8:51:26 PM (Eastern Standard Time, UTC-05:00)  #    
# Thursday, February 01, 2007

[Sorry about the blogging gap - nothing dramatic, just a little case of overworked and underslept. Good excuse to start up again though.]

Imagine a room with a table, no computers, and four really smart people who care tremendously about helping people write software, and who tackle questions like "what keywords should be in this language" every day -- and whose decisions actually will get implemented. A full hour of amazing conversation appeared recently on Channel 9.

How will imperative programming languages evolve to suit the needs of developers in the age of Concurrency and Composability? What role can programming languages play in enabling true composability? What are the implications of LINQ on the furture of managed (CLS-based) and unmanaged(C++) languages? How will our imperative languages (static) become more functional (dynamic) in nature while preserving their static "experience" for developers? 

Answers to these questions and much more are to be found in this interview with some of Microsoft's leading language designers and programming thought leaders: Anders Hejlsberg, Technical Fellow and Chief Architect of C#, Herb Sutter, Architect in the C++ language design group, Erik Meijer, Architect in both VB.Net and C# language design and programming language guru, and Brian Beckman, physicist and programming language architect working on VB.Net.

This is a great conversation with some of the industry's most influential programming language designers. Tune in. You may be surprised by what you learn...

Some quotes and paraphrases that caught my attention:

  • "No language can ignore concurrency and stay successful for mainstream programming over the next five, ten years."
  • our entire industry is based on composable software and we manage to do composable software with the languages, libraries and frameworks we have now. it's rather amazing that we can do it.
  • "all you can do as a language designer is slow down the accrual of new features that will eventually lead to cave in."

Now if you aren't sure you know what a lambda expression is, or what makes a language functional as opposed to imperative, or what LINQ would have to do with that, or what composability is, then you may think you don't want to watch this video. But you'd be wrong! Spend this hour with these gentlemen and not only will you learn all those things, you'll learn why it affects you and why you should be following, at least a little bit, the current work in this area.

Watch it!

Kate

Thursday, February 01, 2007 8:05:14 PM (Eastern Standard Time, UTC-05:00)  #    
# Sunday, January 21, 2007

A lot of people are asking me if I am using Vista, if they should use Vista, if I think Vista will get good adoption, and so on. I have Vista on some machines, still have XP on my ancient primary laptop, and miss Vista when I'm not using it. I tell people this and they assume it's all about the shiny and the seethrough and the pretty. It's really not. For me the fast search is a big thing. And I still consider UAC a feature and have no intention of turning it off or launching everything I do from an elevated command prompt. I like the thumbnails that actually show your content - though I suppose some might dismiss that as "pretty", it's saved me from opening big files with odd names more than once, just so I can tell whether I want to delete them or not. An MSDN article lists a number of useful benefits of running on Vista that have nothing to do with being pretty. Beyond UAC and other security benefits, consider Sleep (fast as Standby, safe as Hibernate), SuperFetch, ReadyBoost, restart manager, presentation mode, ... there's so much! It's not just about the .NET Framework 3.0 -- you can have that downlevel. It really is a new version of the operating system and it does a lot of things a lot better.

So I forgive it for being pretty.

Kate

Sunday, January 21, 2007 5:45:53 PM (Eastern Standard Time, UTC-05:00)  #    
# Saturday, January 20, 2007

I once had an opportunity to write one of those Teach Yourself <Something complicated> in 21 Days books, or it might have been 24 Hours, or A Weekend, I forget. I was overloaded with work at the time and didn't write it. One of the things about writing those books is that nobody actually expects the reader to learn what they need in 21 days or 24 hours or whatever. It's basically the number of chapters. And if you processed one chapter a day, I guess you would cover the book in three weeks, but you wouldn't be a <Something complicated> programmer at the end of that, would you? Some folks might do 5 chapters a day, others might do a chapter a week. It depends on where you're starting from.

I came across a few interesting blog posts on this topic. Peter Norvig found hundreds of such books on programming languages or frameworks, and proposes instead Teach Yourself Programming in Ten Years. He has a point. Jasmine refines the point a bit, saying that if you're already a good developer you probably can pick up a new language or framework in a matter of days, and that if you don't have what it takes to be a good developer, ten years of plugging away at it won't make you good enough.

I've been getting paid to program since 1979, and I learn new things all the time. But I try to learn new languages no more than once a year -- and I wouldn't be able to invest 21 days in learning a language, either. More importantly, I've invested quite a lot of time and effort into spotting those who will be good developers some day, and trying to speed the process of making them better. I think the emphasis on debugging and on reading or fixing the code of others is appropriate. It's tempting to have the newbies work on little projects alone since they can't understand your big complicated project with difficult code written by the really smart people. But trying to understand that project and that code is what will make that newbie a developer -- or show you both that it's a hopeless cause :-).

Kate

Saturday, January 20, 2007 5:37:44 PM (Eastern Standard Time, UTC-05:00)  #    
# Friday, January 19, 2007

I do my searching these days at www.live.com -- the ads are less obtrusive or easier to ignore or something and on the occasions I've done the same search in two places, I like my Live results better. But for the next little while I'm going to use a slightly more complicated URL: http://click4thecause.live.com/Search/Charity/Default.aspx?locale=en-us&source=msnhp. I know, that's a mouthful, but here's the thing - it searches the same, but it also donates to charity. Really! I know we've all seen those "if you forward this to 40 people Microsoft will know and they will give money to charity" emails, but this is different. After all, counting web hits is something that can really be done.

Education and sports programs for refugee youth around the world? Sounds like a good cause to me. Check it out, and make it your new search page, won't you?

Kate

Friday, January 19, 2007 5:20:40 PM (Eastern Standard Time, UTC-05:00)  #    
# Thursday, January 18, 2007

Rory interviews Kam VedBrat about glass, composition, DWM, and other ways to stray from the gray-buttons-and-white-textboxes-on-a-big-gray-background that is the UI most devs naturally create. Watch it!

Kate

Thursday, January 18, 2007 7:32:58 AM (Eastern Standard Time, UTC-05:00)  #    
# Wednesday, January 17, 2007

Try this. Open up Visual Studio and make yourself an MFC app. It doesn't really matter what kind of application it is - a dialog app is probably the quickest to create but you could use some more complex MFC app that you happened to have lying around if you preferred. Build the app and run it to prove to yourself that it's fine.

Now bring up the project properties, and under Configuration Properties, General set Common Language Runtime Support to Pure MSIL Common Language Runtime Support.

Click OK and build the application. Blam! Errors everywhere. My little nothing dialog application got 18 and they all look like this:

1>C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afxv_w32.h(242) : error C3641: 'DrawState' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

1>C:\Program Files\Microsoft Visual Studio 8\VC\atlmfc\include\afxv_w32.h(260) : error C3641: 'DrawStatusText' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

1>C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\winbase.h(1849) : error C3641: 'FreeResource' : invalid calling convention '__stdcall ' for function compiled with /clr:pure or /clr:safe

What does this mean? Well, every function has a calling convention. These include __stdcall, __clrcall, __cdecl, and so on. Many of the functions in the MFC libraries (look at the include files for which these errors occur) are declared to be __stdcall, meaning that they are common-or-garden native C++ functions. But when you compile your application /clr:pure, you are saying "I don't have any common-or-garden native C++ functions in here. Everything is managed."

Since you can't change MFC, you have to change your compiler options. Change the CLR support to just "Common Language Runtime Support (/clr)" and build again. All the errors go away.

Kate

Wednesday, January 17, 2007 12:05:53 PM (Eastern Standard Time, UTC-05:00)  #    
# Tuesday, January 16, 2007

Thottam R. Sriram has an article in the January MSDN Magazine called CLR Inside Out: Introduction to COM Interop. As the introduction says:

COM is a wonderful technology. One aspect of the common language runtime (CLR) that makes it an extremely powerful platform is that it allows seamless interactions between Microsoft® .NET applications and unmanaged COM components. However, when I searched the Web, I found few working samples demonstrating the very basic concepts of COM interop. The purpose of this column is to illustrate those basic concepts in order to provide solid working examples that can jump-start users in this technology.

I'll start off with a simple Active Template Library (ATL) COM server and try accessing methods in this server using an unmanaged COM client, then do the same thing with a managed client. I'll walk through the various DLLs to illustrate the translation from unmanaged to managed, and I'll show how to access an exported method in an unmanaged DLL using P/Invoke. The toughest part of this is to figure out marshaling of complex structures, which I don't cover exhaustively in this column-it would be a complete column (or book) on its own. I'll show you how unmanaged code can call back into managed code using interfaces. (You could do this with delegates as well, but I won't cover that in this column.)

Finally, I'll discuss debugging your COM interop project using public symbols. This will give you very basic introduction to WinDbg.exe, unmanaged debugging, and managed debugging using SOS. I'll demonstrate the stack from managed to unmanaged as calls are made in either direction.

The managed client is in C# -- when you write your clients in C++/CLI you don't have to figure out how to declare and marshal complex structures, after all. And seeing how to call back from native code to managed code is helpful indeed. I'm not sure if Reverse P/Invoke is the official name for this, but it works for me. You set up an interface in your C# code and decorate it with attributes for COM. Then you implement that interface in your code and use tlbexp to make a COM Callable Wrapper around your .NET object. Then you hand-define the same interface as a COM interface in your native code and you're all set. The .NET code can P/Invoke some native function and pass in a reference to the .NET interface. By the time it's unmarshaled over in the native world, it's become a smart pointer to that COM interface and you can invoke the method from the native code. It's a little tricky, but it's not hard - once you've seen it done.

Since the article wraps up by touching on Windbg, there's something for everyone. Check it out!

Kate

 

Tuesday, January 16, 2007 11:42:47 AM (Eastern Standard Time, UTC-05:00)  #