r/cpp • • Mar 14 '26

Discussion of Code Structure and Code Complexity Implications of Basic C++ Language Features

After 10 years of programming professionally in C++, I came to realize that I generally prefer a simpler subset of the language for my day-to-day work, which mainly involves desktop application development.

Working in a 30 year old code base for so long, you get to see which design decisions panned out and which didn't. This lead me to think about the technical reasons for why certain C++ language features exist, and what long-term impact they have in terms of code complexity and code structure. The result is a somewhat lengthy and very subjective article that I would like to share.

You can find the article here:

https://slashbinbash.de/cppbas.html

The premise of this article is: if you use simple language tools you can concentrate on solving the real problems at hand, rather than solving language problems. This is very much inspired by listening to interviews with Casey Muratori, Jonathan Blow, Bill "gingerBill" Hall, and others.

I discuss several aspects of the C++ language like functions, structures, statements, enumerations, unions, arrays, slices, namespaces, classes, and templates. But I also go into topics like error handling, and ownership and lifetime. I finish the article with a chapter about code structure and the trade-offs between different approaches.

The goal of this article is to give the reader a sense of what code complexity and code structure means. The reader should be able to base their decisions on the technical aspects of the language, rather than the conceptual or philosophical reasons for why certain language features exist.

I'd be thankful for any feedback, corrections, and ideas that you have!

Note: I still need to clean up the article a little bit, and add a few paragraphs here and there.

24 Upvotes

31 comments sorted by

View all comments

Show parent comment

1

u/FlailingDuck Mar 14 '26

For sure, I'm in the same boat, heavy legacy codebase, closed source dependencies, lack of test coverage, egregiously poor design decisions that cannot be changed without throwing the whole system out.

But I just try to lead by example, encourage modern practices, you can explain the justifications and reasons why old decisions are bad or poorly thought out, but letting the juniors see how new code added is a much needed improvement over the old.