Articles & Books

C++, C# and Unity

The place C++ will have at Unity:

C++, C# and Unity

by Lucas Meijer

From the article:

C++ is not great at this task. I want my loop to be vectorized, but a million things can happen that might make the compiler not vectorize it. It might be vectorized today, but not tomorrow if a new seemingly innocent change happens. Just convincing all my C/C++ compilers to vectorize my code at all is hard.

Ranges, Code Quality, and the Future of C++--Jason Meisel

Very intersting comment about ranges.

Ranges, Code Quality, and the Future of C++

by Jason Meisel

From the article:

Many of you have seen the recent blog post by Eric Niebler about the acceptance of his C++ Ranges proposal to the C++2a standard. This is a feature set I’ve wanted in C++ for some time. In fact, using C#’s standard LINQ library, I’ve become accustomed to writing code in this style.

I found it unfortunate, then, to see people respond to this post on Reddit and Twitter by complaining that this feature makes code unreadable. Apparently, C++ is becoming more complex and less useful.

I think this is completely untrue. C++2a is going to be the best version of C++ yet, and a big reason for that is Eric’s Ranges library.

But even to me, his Pythagorean Triples example is bad code. This is not because this range library makes code harder to read, but because he utilizes the library very poorly...

A Free Ebook on C++ Smart Pointers--Jonathan Boccara

Nice way to learn more.

A Free Ebook on C++ Smart Pointers

by Jonathan Boccara

From the article:

To write expressive code in C++, mastering smart pointers is a necessity! Without them, our code becomes littered with memory management, news and delete, and unclear semantics about who owns what resources.

If you’re part of my mailing list (which you can join at the bottom of this post), you will get as a Christmas gift a free ebook of more than 50 pages of selected contents of Fluent C++ about smart pointers. Of course, you also get access to the ebook if you’re a Patron of Fluent C++...

The SoA Vector – Part 2: Implementation in C++--Sidney Congard

The series continues and end.

The SoA Vector – Part 2: Implementation in C++

by Sidney Congard

From the article:

Like we saw in the first part of this series on SoA, the SoA is a way to organise the data of a collection of objects to optimise the performance of certain use cases: traversing the collection by accessing the same data member of all the objects:

struct person {
   std::string name;
   int age;
};

std::vector<person> persons = ...

for (auto& person : persons)
{
   ++person.age;
}
struct person {
   std::string name;
   int age;
};

std::vector<person> persons = ...

for (auto& person : persons)
{
   ++person.age;
}

The SoA in its barest expression is this:

struct persons {
    std::vector<std::string> names;
    std::vector<int> ages;
};
struct persons {
    std::vector<std::string> names;
    std::vector<int> ages;
};

By putting all the ages next to each other in memory, we optimise the performance of the traversal. But such a structure is not a container in itself, and is in particular not compatible with the STL.

Let’s design an SoA collection with an interface as close as possible to std::vector<persons>, but with the SoA structure of components stored in separate arrays...

C++ ... in 2018 -- Bartłomiej Filipek

cppin2018.PNGA retrospective of all the things that happened in C++-dom in 2018:

C++ ... in 2018

by Bartłomiej Filipek

From the article:

2018 is almost over (just a few hours left in Poland till midnight). As in previous years, I did a summary of many things that happened in the C++ community. This year seems to be marked with a solid progress towards the standardisation of C++20, using more and more C++17 and as always the growth in the community.

Let’s have a look...

TODO_BEFORE(): A clean codebase for 2019 -- Aurelien Regat-Barrel

2019.PNGMay your new years ever be happier than your old years -- now there's a great use for a monotonically increasing function!

Here is the latest uplifting contribution, with thanks to the Fluent C++ blog:

TODO_BEFORE(): A clean codebase for 2019

by Aurelien Regat-Barrel

From the article:

How and why do we accumulate technical debt in the first place? How do we find ourselves in a situation where things seem to be out of control? And more importantly: how to recover and improve from such a situation? ...

How To Parallelise CSV Reader with C++17 - new chapter in C++17 in Detail

Just before Holiday Break, I've added a new chapter to my book:

How To Parallelise CSV Reader with C++17 - new chapter in C++17 in Detail

By Bartlomiej Filipek

From the new chapter:

In the new chapter, you’ll see how to build a tool that works on CSV files, parses lines into sales records and then performs calculations on the data. The code uses many C++17 features. You’ll see how easy it is to add parallel execution to selected algorithms and have a performance improvement across the whole application. In the end, we’ll discuss problems that we found along the way and possible future enhancements.

A brief introduction to Concepts – Part 1--Glennan Carnie

Useful new feature.

A brief introduction to Concepts – Part 1

by Glennan Carnie

From the article:

Concepts allow us to express constraints on template types with the goals of making generic code

  • Easier to use
  • Easier to debug
  • Easier to write

In this pair of articles we’ll look at the basics of Concepts, their syntax and usage.  To be open up-front:  this article is designed to get you started, not to make you an expert on Concepts or generic code...

Did anybody consider adding a language pragma to C++?

Interesting question.

Did anybody consider adding a language pragma to C++?

From the article:

For people who don't know, language pragmas are the way that ghc (Glasgow Haskell Compiler) allows you to turn on and off language features. In C++, this would mean that I can write something like:

#language <no_c_style_cast>

And that would disable C-style cast for that source file. Don't you think that it would be useful to standardize this to allow people to willingly disable some old legacy C++ features in newer code?