Hi C++ developers! This article is the first one of its series on how-to learn the modern C++ and upskill yourself. In this series, I will share some of the most interesting talks I have found in the web. If you want to notify me about a video, please do not hesitate to contact me.
In my blog, I’ve already suggested some books to learn the modern C++ programming. Books are great, but sometimes talks and videos are very helpful too. For this reason, I want to start from this talk from James Pascoe: “How to master C++ – Accu 2023”.
The main points of the talk
The talk covers the many attitudes that are required to master C++.
The following five attitudes are discussed by Jim (James) Pascoe:
- Imperative mindset: This attitude involves directing the computer how to solve a problem step by step.
- Functional mindset: The functional mentality is an approach to coding that emphasizes the use of functions. In this perspective, code is viewed as a collection of functions, with the emphasis on the functions’ inputs and outputs. A functional mentality has a number of advantages. For starters, it can make code more concise and understandable. Second, because functions may be readily coupled to build additional functionality, it can make code more reusable. Third, it can improve code efficiency by optimizing functions to prevent needless computations.
- Efficiency: The efficiency mindset is an important one for any programmer to have. By writing efficient code, you can make your programs run faster and use less resources. The presenter discusses about possible techniques to reduce the cost of running your programs, e.g. evaluating hit and misses of the cache, the efficiency of the branching, etc.
- Concurrency: This attitude focuses on developing code that can handle several tasks at once. Jim also points out the difference between concurrency and parallelizing: concurrency is about handling multiple tasks (generally sharing some resource), while parallelizing is about executing multiple tasks “at the same instant”. Parallelizing is generally linked to the usage of additional resources.
- Debugging: This attitude is concerned with locating and fixing issues in your code. For example, it is critical to consider debugging while creating your code. The presenter also advises you to include features that will aid in debugging, such as synchronised logging and crash dump retrieval.
The ability to switch between different mindsets is an essential skill for any programmer. By being able to recognize when you need to switch mindsets, you can write more efficient, expressive, and debuggable code.
For example, when writing code that must be efficient, you may employ an imperative mindset to instruct the machine on how to tackle the problem step by step. When writing code that has to be expressive, you may use a functional mindset to communicate your intent without worrying about how it will be performed. Also, when writing code that must handle multiple tasks at once, you may employ a concurrency mindset to ensure that the jobs do not conflict with one another (“take a step back, design…”). When writing code that needs to be debugged, you may need to move to a debugging mindset to find and fix issues.
For each type of mindset, the presenter provides some reference to books and articles that can be extremely helpful to acquire the relevant skill (I really love this!).
Finally, Jim points out that mastering C++ takes time and exercise. You may, however, become a master of this sophisticated programming language if you are ready to put in the effort.
Enjoy the talk!