WinRT, Projections, and COM

Martyn Lovell gave a great talk on the new Windows Runtime at Lang.NEXT this week. You know it’s going to be a good talk when the speaker uses the word “soporific” four seconds into the presentation.

One of the ideas I found interesting was language projections, providing multiple programming languages idiomatic access to the lowest level system APIs. What’s new is that these projections are not hand-crafted interfaces but software to create interfaces. The operating system calls are described in metadata that the projections use to create language-specific interfaces. This prepares the way for future growth.

In years gone by, Microsoft would first make an API available to C++, then make it available to VB in a later release. But starting with Windows 8, all languages will have immediate access to new features as they are released. Microsoft is writing projections for .NET, JavaScript, and native code. Third parties will write projections for other languages. If an obscure language has a projection, it will gain access to new runtime features at the exact same time that C# does.

Another point I found interesting is that WinRT is reusing some ideas from COM. I thought the basic ideas of COM were brilliant, though in practice COM development was painful. Near the end of the video (42:17), Martyn Lowell explains how WinRT relates to COM.

Philosophically, COM was about taking a world of different languages and using interfaces to abstract them. And we’re about taking a world of different languages [and abstracting them] so in that sense the philosophy is similar. But if you worked with COM at the time, as I did quite a lot, there were a lot of pain points. … The piece of COM that is largely unchanged in Windows Runtime is IUnknown and the marshalling and proxy system. Beyond that, almost everything you can see about the Windows Runtime is about re-imagining an interface-based system …

If COM brings back bad memories, understand that Microsoft is not saying you need to go back to writing COM, only that they’re using ideas from COM to provide you higher-level interfaces.

One thought on “WinRT, Projections, and COM

  1. Speaking of the COM basis of WinRT, the excellent Ian Griffiths has demonstrated a while ago how WinRT programming looks in C++ when you aren’t using language projections. It’s HRESULTs all the way down:

    Nobody is going to want to suffer through that, but it’s worth noting that the C++ language projection (modeled on C++/CLI for .NET) is incompatible with standard C++. It uses non-standard syntax extensions which means your code will not compile on anything but Visual C++. The projections are elegant, no doubt, but they are also a standards breach and vendor lock-in of the kind that the C++ community rejected very firmly in the case of Managed C++ and C++/CLI. We’ll see if WinRT has better luck than its spiritual predecessors.

Comments are closed.