C++ Evolution: Modern C++ Best Practices for Application Software

Some notes on "modern C++". The C++ programming language was first released in 1985. There have been multiple updates to it that are labeled by the year, C++03, C++14, C++20, etc. With a few tiny exceptions, a newer compiler that defaults to a newer version of C++ will still compile code written based on the original release. Some of the additions to C++ have been things every code could benefit from. An example is RAII (Resource Acquisition Is Initialization), which prevents memory leaks. The big change in C++ over the years is the ability to make template libraries and a rich set of template library functionality that comes with C++. Templates are generic functions. For example, numeric functions where you write one function and it automatically converts to float, double, or integer data types. Many of the additions to C++ have been designed for writing template libraries. Along with the changes to the language, we have gotten changes to the way books recommend using the language which are called "Modern C++". Modern C++ coding styles typically utilize features in C++14. Modern C++ coding style relies heavily on using the included template libraries, and writing code like it were a template library. I recently looked at a piece of open source scientific simulation software that was heavily templated. Much of their coding style didn't give any benefit to their purpose of writing good simulation software, and indeed made the code harder to follow and modify. It had more complex syntax and layers of code. This is a coding style I call "smart but not wise". Unfortunately, some books on C++ are written assuming everyone is writing template libraries. These books don't show wise choices for writing applications software using C++. Part of good software development is making wise choices for your application, not just copy and pasting examples designed for a different type of software.

To view or add a comment, sign in

Explore content categories