Nobody Understands

Top 5 Myths About C++

We've now completed 5 articles in the "Nobody Understands C++" series so here we are going to recap the misconceptions we have covered.

  1. You shouldn't use all the language features of C++, that just makes your code too complicated! Wrong, we learned that by using some of the less used features of C++ we can make our code much more succinct.

Nobody Understands C++: Part 5: Template Code Bloat

On occasion you will read or hear someone talking about C++ templates causing code bloat. I was thinking about it the other day and thought to myself, "self, if the code does exactly the same thing then the compiled code cannot really be any bigger, can it?"

Here are the test cases presented, first without the use of templates, second with the use of templates. Exactly the same functionality and exactly the same code output:

Nobody Understands C++: Part 4: Functional Programming

Standard Algorithms

Few C++ developers seem to appreciate that the standard C++ library is actually designed around functional programming principles. The standard library headers algorithm and functional header files provide functional algorithms and facilitate their use, respectively.

As usual we will try to provide a simple example of why we should put to use the functional techniques in the standard library.

Nobody Understands C++: Part 3: Templates

C++ templates is a huge topic that we will not fully cover here. While we have covered templates in the past, this article will cover the very basics and the reasons why we would want to use templates.

A simple case of why you would want to understand templates is wrapped up in a question I used to ask when I would interview C++ developer candidates, "write for me a max() function which can compare any two values of the same type."

Nobody Understands C++: Part 2: RAII

Understanding RAII is critical to understanding good C++ design.

RAII stands for "Resource Acquisition Is Initialization." The basic idea is that an object fully manages all of its own resources.

Understanding object lifetime is critical to understanding RAII. For the purposes of this article we will only be discussing objects created on the stack, not on the heap. That is, objects not created with "new."

There are just a couple of simple rules to understanding lifetime:

Nobody Understands C++: Intro

This is going to be the first post of several, though I'm not sure how many just yet. The title of the post should be self explanatory, but I will elaborate. It is my strongly held belief that C++ is generally poorly understood and gets a bad rap because of this. It is also my belief that this is NOT the fault of C++, but rather the fault of old-school C++ developers who learned the language before the language was ratified in 1998.

Syndicate content