E-Books: Foundations of C++/CLI
The Visual C++ Language for .NET 3.5
The Visual C++ Language for .NET 3.5
Foreword by Brandon Bray
Few things excite me more than thinking about the potential of software. It sounds contrived, but it’s true. To that end, programmer productivity is essential to building great software. It’s easy to look at C++ and begin lauding it for powerful techniques like templates and low-level control, and likewise C++ is vilified for complex preprocessing and loose type safety, among other things. Yet C++ is one of the most productive programming languages on the market.
Early on in the design of C++, a conscious decision was made to make C++ highly compatible with C. That philosophy persisted as the language evolved—existing code matters! When new system technologies like COM appeared, C++ directly supported them without forcing programmers to discard code already written. So, when .NET came about, there was no question
that C++ should enable programmers to leverage value from their existing code while using the .NET Framework.
Of course, the first few attempts at integrating concepts from .NET into C++ proved to be a challenging task. Nevertheless, the first release of “Managed C++” laid the groundwork for what was to come. Customers taught us that syntax matters; a good language is a balance between utility and elegance.
At this point, I started involvement in the project. As the person tasked with writing the specification, it is easy to associate me with the development of C++/CLI. Yet this truly was a collaborative effort that involved intense discussion, experimentation, feedback, iteration, and advocacy from hundreds of people. Developers, testers, customers, book authors, standards advocates, bloggers, and even journalists gave feedback that changed C++/CLI in some way.
The end result is a language that enables developers to maximize their usage of C++ code in existence while giving them the freedom to explore the possibilities of the .NET Framework.
C++/CLI is a language that strengthens the value of both managed and native code. Complexity is still a concern, but I am satisfied that the essential concepts of managed code show through in an elegant manner.
I am excited that you have Gordon’s book in your hands. With it, you will take away incredibly valuable skills. After all, the software you create has the potential to change the world.
Brandon Bray
Senior Program Manager, Microsoft
Senior Program Manager, Microsoft
Foreword to the First Edition
A person standing on the side of a river shouts to someone on the opposite bank: “How do you get to the other side?” The second person replies: “You are on the other side.” -Chris Gosden C++/CLI is a binding of C++ to Microsoft’s .NET programming environment. It integrates ISO C++ with the Unified Type System (UTS) of the Common Language Infrastructure (CLI).
It supports both source-level and binary interoperability between native and managed C++. As the Gosden quote suggests, it is how one gets to the other side, regardless of where you happen to be standing. The actual details of how you do this are covered in Gordon’s fine text.
In primitive societies and adolescent fantasy novels, such as The Lord of the Rings (which, along with Remembrance of Things Past, is one of my favorite books), names have a kind of magical aura to them—they need to be handled with extreme care and protected. The same holds true in computer science, apparently—or at least within Microsoft. Although you hold in your hand the first book devoted solely to C++/CLI, I couldn’t for the life of me find any specific reference to C++/CLI in the Visual Studio 2005 release—at least not in the Visual C++ IDE, in order to open a C++/CLI project, or in the “What’s New” section of the documentation. This whole notion of binding C++ to .NET has a sort of fantasy aspect to it that has clung to it since the original Managed Extensions to C++ in the Visual Studio .NET release of 2001. C++/CLI is the noncompatible and more elegant replacement for the Managed Extensions. It is how we program .NET using what the book’s subtitle calls “the Visual C++ Language for .NET.” That’s what Gordon’s book will teach you how to do.
As Gordon states in his introduction, C++/CLI represents an evolution of C++. This does not, of course, imply that C++/CLI is a better language than C++; rather, C++/CLI is better adapted to the current and future computing environment that we work in. If you are a Visual C++ programmer with legacy “native applications” and need to move or extend these applications to .NET, C++/CLI is an essential tool for your survival, and Gordon’s text is an essential first step to mastering this tool.
An aspect of evolution is an increase in structural complexity, and this, too, is reflected in C++/CLI: knowing C++ may or may not be a help in understanding C++/CLI! For example, here is no such thing as a destructor in .NET, so although the syntax resembles that of the native C++ destructor, its behavior is oddly counterintuitive: you simply can’t fully understand its operation by its analogous form. And this is where Gordon’s text becomes invaluable both as a tutorial and a desktop reference. It is for this reason that I highly recommend it.
Stanley B. Lippman
Former Architect, Visual C++
For Download: