Some of us folks who have been coding using C++ have never left the C++ fold as other languages have come into vogue and gone out of fashion. We did take an occasional peek and try to understand what the hoopla over a new programming language was all about, and made efforts to learn concepts that we were able to successfully apply in our daily routines using the best tool for the job. As C++ programmers, we constantly remind ourselves: one size does not fit all.
These days, there is an increasing number of folks who are either moving back to coding in C++ or are beginning the process of transition into C++. While I will not delve into the reasons or motivations for their change of heart, it is worth noting the number of learning resources that are being created to cater to folks approaching C++ from other programming languages. One such resource is the book titled “C++ Succintly” written by Michael McLaughlin and published by the SyncFusion Technology Resource Portal.
Disclaimer: I reached out to Sync Fusion asking for permission to use their icons for my upcoming book. While granting permission for the same, SyncFusion asked me to review one of their books/products and as a compliment for reviewing their product; they have offered a personal key to one of their products. I must note that their offering is not affecting my review of the book.
Michael does a good job of distilling the large number of C++ features into a palatable set for the C# developers, who are the target audience for his book. He does a commendable job of mapping C++ concepts that do have C# equivalents and ones that folks are familiar with. The book starts off with an introduction to the C++ type system and then moves on to explaining namespace and functions/classes. All of these concepts are explained while contrasting them with equivalent C# constructs thereby helping the C# developer rationalize the C++ constructs.
Once the basics are explained, the focus moves to Constructors and Destructors. Object lifetimes and behavior is obviously very different in C++ when compared to GC-controlled languages and the contrast is explained using C++11 memory management smart pointers: shared_ptr, weak_ptr and unique_ptr. One of the most widely used paradigms in C++, for object destruction, is the Resource Acquisition is Initialization or the RAII pattern. This pattern is widely used in the C++ world to design well behaving programs that do not leak! When put together with object creation, destruction and a pattern to manage lifetimes, it becomes increasingly clear why C++ programmers shy away from having to use a GC. The book does a good job of explaining these concepts to C# developers.
The focus then shifts to explaining pointers: a perennial source of confusion and frustration to a lot of non-C++ developers, references and using ‘const’. All of these concepts are explained in a brief and succinct format. This chapter then leads to a discussion on strings, all the more relevant since there are a multitude of string types supported by C++: from plain char* to std::string types.
A few C++-esque idioms are introduced along the way, including the use of pre-increment operator within a ‘for’ loop, using ‘nullptr’ instead of NULL etc.
The final few chapters focus on templates, C++ lambdas, the Standard Library and finally a chapter devoted to using Microsoft Visual Studio and C++.
All in all, it is a good book for explaining C++ in a succinct format for non-C++ developers, especially for folks using C# and are probably staring at the prospects of having to use C++ in one of their upcoming projects. This book however is not an encyclopedia of C++ nor does it cover everything that is part of the modern C++ programming language. In all fairness to the author, he does make it very clear at the beginning itself, that this book does not cover everything but instead only focuses on aspects of the C++ language that folks from non-C++ world find useful and enhance their knowledge/skills. For the folks who are in the C++ realm already, there is little value in this book, unless you are not up-to-date with C++11. If you are still coding using the older C++98 style and want to get a good digest of C++11 features, definitely read this book. For non-C++ folks, this is a good “go-to” book to get you started with modern C++.