C++ : Making Codebases Simpler
I was introduced to CppCon by my mentor and team lead Kevin Nuwer. He mentioned, “Since you are interested in learning more about C++ Modern Constructs and what is going on in the committee you should be able to get knowledge from the lectures presented in CPPCon.” Let me begin by stating what is CppCon? As I quote from the website, “CppCon is the annual, week-long face-to-face gathering for the entire C++ community.”
All the eminent people of the C++ community starting from the founder Bjarne Stroustrup, along with people like Jason Turner, Matt Godbolt, Dan Saks, Kate Gregory and so many more present their views/talks on diverse topics in C++. I had started with the “Back to Basics” track from 2020 CppCon talks and was in love with the “Smart Pointers” talk by Rainer Grimm, “Design Patterns” by Mike Shah, “Unit Tests”, “Concurrency” and so many more topics. These are things we use in our daily lives while programming in C++ but we sometimes fail to make things simpler. The modern language has provided us with so many constructs to make lives simpler. People on the committee advocate for range-based for loops, use of “consts” and “constsexpr”, use of smart pointers as compared to raw pointers. Once we look at the benefits of these features we are just mesmerized by the beauty of the language.
I wanted to write this article based on a talk by Kate Gregory titled “Simplicity: Not Just for Beginners”. She presented this talk at the CppCon 2018. As the name suggests, the whole point was how do we make our code look simpler. She mentions the moment the code will leave our fingertips, we are the first one to read it within microseconds, and then for years to come that codebase would be maintained by our companies if we have written code that is maintainable, testable and of course simpler. The language provides us options to fulfill all these criteria. It has well-defined, and tested libraries, various algorithms which can solve our complex problems in seconds, and well-documented materials, or videos on the internet to learn the language. As she mentions and I firmly believe it is difficult to write complex code, but it is more difficult to write simple code, a code that is “fun” to work with. Using proper design patterns, modern CPP constructs, and writing Unit Tests for the production code makes a programmer’s life simpler. By programmer here I mean the one who writes the code and the code who reads it and maintains it.
When I started learning C++, I was amazed to learn about how easily we can write into files. The insertion operator makes it so easy to write into a “stringstream”, the syntax is smooth, and we do not have to maintain pointers; while using “FILE *ptr” which looks difficult. There are a couple of other talks which I would refer to in case people are interested like “Oh The Humanity!”, and “Stop Teaching C”. Anyone who wishes to learn more about C++ should go through these talks. Just like I grew my interest in the language I am sure, these wonderful committee members of the C++ community will and should influence your thought process. Trust me, learning C++ modern constructs and using them in your day-to-day life will make your codebases beautiful.
Please follow, like, comment, share if you like this.