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.
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
IUnknownand 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”
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.