What’s that “new” doing in my inner loop?

I didn't think my code was running THAT slow, but it's always nice to periodically take a break and think of performance. Now we all know that the right way to approach code optimization is to profile the code rather than rely on our intuition, but there are a lot of things we know are …

Advertisements

An amateur’s view of clang and gcc

I was happily tinkering away with some C++ code on my mac. The only fancy thing I had done was to replace the bundled compiler with clang 6.0 which supports C++17 (because I wanted to use std::optional - long story). My program was compiling and working and I was happily building it out when I …

Python vs C++: reading a binary file

While adapting some binary file parsing code from Python to C++, I was struck by 1) the supernatural shape shifting power of Python and 2) the opacity of the resulting code - which turn out to be two sides of the same coin.

Inline virtual final

I was looking into virtual functions (that link is the most succinct exposition I have seen) for some of my code. And I began to think, huh, won't this slow things down? The code first has to go to a virtual table and then look up the correct function - that's a WHOLE extra step. …

C++: how to order class declarations

Of course, this is all a matter of opinion. When I started out writing C++ (back in the days of glBegin() and glEnd() ) I followed the convention (which I found in books and example code) of putting all the member variables first, then all the member functions. There was  much hand-wringing about whether the …

C++: Notes on moves and copies

I found the behavior of Objects in STL containers a bit confusing, so I wrote down some notes for myself. (I've updated this post after helpful comments from my colleagues Vladimir Semenyuk and Björn Pollex. They pointed out that I hadn't implemented copy and move constructors in my original code. Hopefully the post now looks …