[Bf-committers] Making C++11 required for blender2.8 branch

Ichthyostega prg at ichthyostega.de
Thu Oct 6 15:57:16 CEST 2016

On 04.10.2016 11:15, Sergey Sharybin wrote:
> I would like to propose to switch to C++11 in blender2.8 branch. Such a bump
> was already discussed in the past, but i want to give it a real pus forward
> now.

On 04.10.2016 16:43, Sergey Sharybin wrote:
> let's state the obvious: Blender's core is and will be a pure C.

Hi Sergey,

after reading this thread, it looks like the "elephant in the room"
has not been mentioned. Regarding C++ this is the use of exceptions.

Exceptions are one of the most beneficial features of modern C++
BUT only if you go whole circle, and that means to use RAII *everywhere*.
I have seen several times, that when you really go that path, the code size
shrinks to about one third, the code becomes a thousand times more clean and
readable and a lot of painstaking long-standing quality issues just resolve
into thin air. This is a huge productivity boost, and in comparison, the good
old C-style of resource management is just a huge waste of developer effort.

BUT, as said, this only works if you're able to go that path totally.

And I have seen numerous instances, where people switched half-heartedly
and where not able to let go with the "good" old C habits. In that case,
exceptions are a dangerous poison, and have the potential to kill a code base.
You'll soon find every place littered with cascades of try-catch blocks and
you'll be haunted by occasional random segfaults, which are near
impossible to diagnose or fix.

Thus I'd recommend to use either one of the following, and never mix things up.

 - do *all* error handling with exceptions
 - disallow the use of raw pointers. Wrap *every* resource into a RAII object
 - disallow the use of try-catch blocks. In code review, request a proper
   justification for every single catch.

 - disallow the use of exceptions entirely
 - disallow the use of smart-pointers, since they are pointless now and
   might lure people into a programming style which can be dangerous and
   simply does not work with such a setup.

Since we all know the existing code base of blender and our existing
developer resources, the second approach looks more viable.

-- Ichthyo

More information about the Bf-committers mailing list