Comparative review with C++/CLI: The Visual C++ Language for .NET by Gordon Hogenson
Microsoft Visual C++ 2005 Express is one humdinger of an integrated development environment, what is more, you can download it free of charge from Microsoft. Once one has it, one naturally thinks "How can I make maximum use of this thing? And what's CLR all about?" I have echoes in my mind of people saying to me "You know boy, your trouble is that you are always trying to run before you can walk!" But surely, if one has no interest in running, one is unlikely to care much about walking either. I confess though, my classic C++ is still at the toddler stage. But what better time to start thinking about a major new extension to the C++ language?
For those you don't know, CLI (Common Language Infrastructure) is an ISO/ANSI (language standard) specification for a virtual machine environment in which to run executables. The CLI specifies a 'standard intermediate language', which for .Net is the Microsoft Intermediate Language. The intermediate code is compiled by a just-in-time compiler at runtime, so the target machine has to have a version of the .Net Framework installed as a component of the Windows operating system. Microsoft's implementation of the CLI is known as the Common Language Runtime (CLR).
Since C++/CLI is essentially a superset of ISO standard C++, I innocently assumed that I would cover the gap that separates them with one small step, but it turns out that a giant leap is required, and you need expert guidance for setting the correct glide slope and velocity on landing. (Strictly speaking, this may be found in the Help system for Visual C++ 2005 Express, but that's like entering a centrifuge unless you know what you are doing already.)
The Mullah Lippman thinks C++/CLI is a jolly good idea, whilst the Chief Mufti Stroustrup has declared it to be an ungodly tendency:
"The wealth of new language facilities in C++/CLI compared to ISO Standard C++ tempts programmers to write non-portable code that (often invisibly) become [sic] intimately tied to Microsoft Windows ... CLI is "language neutral" only in the sense that every language must support all of the CLI features to be "first-class" on .Net."
Dare I risk my mortal soul? Well, I think its worth a serious look. Whilst classic C++ programming is a more 'pure' form of the art, programming with C++/CLI promises to be an easier, more productive and practically useful activity, apart from the fact that its primary purpose is to produce applications which target the .Net platform, which is all about interoperability between different programming languages.
There seem to be few books catering to the C++/CLI novice, certainly none within a day's march, but I found two possible titles on www.apress.com: C++/CLI: The Visual C++ Language for .NET by Gordon Hogenson, and Pro Visual C++/CLI and the .NET 2.0 Platform by Stephen R. G. Fraser.
The publisher's promotional blurbs for these books are very similar, making it difficult to make a rational choice between them. The 'Pro' in Fraser's title suggests that it might be more difficult to digest, but the larger page count (961) suggests that it might have more comprehensive coverage of the subject, and /or have more detailed explanations.
I plumped for Hogenson's book initially. It has a total page count of 448. It is an unusually comfortable tome to handle, for one describing a computer programming language.
This book serves well as an introduction to C++/CLI programming, but the author makes no pretence to its being fully comprehensive. He assumes the reader to be proficient in classic C++, or another language targeting .NET. The book is billed as addressing the .Net Platform version 3.0 (which is a superset of version 2.0), but as far as I could tell, the author does not expound on any of the extra class libraries it contains (chiefly concerning 3D vector graphics, communication between applications, task automation, and digital identities).
By chapter four, I was finding this book very hard work. I then discovered that you can buy PDF versions of many Apress titles, including Pro Visual C++/CLI, from their web site. A paper book with over 900 pages has got to be a pretty cumbersome thing to handle, and since my laptop computer keeps me warm in the winter, I thought I would give the PDF a try.
This book does have a larger scope than Hogenson's. Fraser, for instance, has a lot to say about the very significant topic of Windows Forms, whereas Hogenson mentions it only briefly. Despite the 'Pro' in the title, Fraser's book takes things at a more leisurely pace and is kinder to the less experienced reader.
After a while I got used to this rather unnatural way of reading a book and appreciated the ease with which you can find references and copy and paste material into a notes file. If my laptop had enough grunt to drive MS Visual C++ 2005 Express I could try out the sample programs as well. Of course, I could do this on my desktop PC but after the day's work I have usually had enough of sitting at a desk.
Quite early on I needed to understand the concept of 'member properties' - one not used in classic C++. Hogenson's multi-faceted explanations were beyond my comprehension until I had read Fraser's. In only a few sentences he satisfied my curiosity and I was able to proceed, whilst accepting that I would need to return later.
Fraser shows screen shots of program output; this saves you the trouble of trying out stuff yourself (except in cases where you just don't believe him), since it adds a touch of realism. Hogenson lists program output as printed text between horizontal rule lines; this has the advantage of being more legible.
Fraser's PDF book is fairly stuffed with typing errors. I noted 30 in the first 156 pages (is this more than the national average?). They do force one to think about what the author really means, which is not a bad thing, but it can become irksome.
Hogenson's errors are more difficult to spot and fewer on the ground (averaging one per 28 pages, in the first few chapters). Being a senior Microsoft technical writer, he may care more about that kind of thing.
In conclusion, the electronic Fraser has been better value for money, whilst Hogenson's book is still entertaining when I am too far away from a mains power receptacle to give life support to my old laptop. Now that summer's coming on I just might buy Fraser's paper version too.