CppCon 2014: Titus Winters "The Philosophy of Google's C++ Code"

CppCon · 69K views · 2014 · 1:00:04

Open on YouTube

C, C++, Rust, Go & systems languagesSoftware practice, open source & careerstalkdated

Why Stack Overflow recommends it

Stack Overflow users link it when asking about or explaining Google's C++ practices, such as its Status error-handling class, forward declaration advice, and the no-exceptions rule.

Recommended by 1 people across 1 different months, 2014 to 2018.

What it is

A CppCon 2014 talk by Titus Winters, who works on Google's core C++ libraries and helps maintain the Google C++ Style Guide. He explains the philosophy behind rules like 'no non-const references' and 'no exceptions', and argues Google's C++ is not outdated.

What people said

Recommends cdunn2001 · 2015-02 · Stack Overflow · on “jsoncpp formatting problems”

@LightnessRacesinOrbit, On the Google C++ Style Guide, I am a big fan of at least one particular rule [LINK] , and I recommend Titus' CppCon talk [this video] . But I think we can add the `settings()` methods for those who prefer that. No problem. Glad you enjoy the library! It is feature-rich, but without the *Builders* (added recently) it was a bit hard to maintain, especially with binary-compatibility.

Cites Arnaud · 2014-12 · Stack Overflow · on “How to prevent compilation if an error status is ignored?”

During his talk [this video] at cppcon, Titus Winters states (at 42:00) that they have a Status [LINK] class. What is magic about that class is that a C++ build is supposed to fail if a Status object is returned and nothing is done to it (Note that it is possible to explicitely call IgnoreError() if this is the correct thing to do). How is such a thing possible? As far as I can tell, the Status class has nothing very special. I suppose they have to hack that rule into their build process but how can one do that?

Cites InsideLoop · 2015-04 · Stack Overflow · on “How Google deals with errors in C++”

Google does not use exception in their C++ code base. For errors, they use a class called status than the programmer must check when it is returned from a function. Otherwise the program does not compile (link [this video] at 41:34). I have a few questions: 1) Is there any example of that class on the web freely available? 2) That's okay for "void f()" that work with side effects that you turn into a "Status f()". But what if your function already returns a value? Google does not allow to pass references that are not const so you can't mutate a Status object given to you. So how do they do? Thanks for your help.

Cites user1610950 · 2015-10 · Stack Overflow · on “Exception vs Non exception handling in c style languages”

This question was brought to me because I was watching this talk [this video] A large part of the second half of the talk is spent kinda going back and fourth about exception vs non exception handling in c++. I am working mainly with c but I would like to get some experienced programmers help understanding this. I haven't written any code that really did anything with exceptions, I have done java code and that basically forces you to add try/ catch blocks etc. When he says exception handling vs non exception handling does that mean the way java almost forces you to add those blocks around any unsafe code while in c basically if you don't remember to do it your app will just crash?

Cites Quokka · 2016-11 · Stack Overflow · on “Why does Google Style Guide discourage forward declaration?”

From Titus Winters' CppCon 2014 talk [this video] : The big one that we've learned lately is: Forward declaring anything with a template in it is a really bad idea. This led to maintenance problems like you would not believe. Forward declaration may be okay, in some cases? My suspicion is the rule is actually going to change to: Library owners are encouraged to provide a header that specifically forward declares the things that they think are worth it (emphasis added), and you probably shouldn't forward declare yourself, and nobody should ever forward declare a templated type. We'll see. We're still working out the [inaudible] details from what we've learned. So maybe issues with trying to direct

Critical nwp · 2018-02 · Stack Overflow · on “Google C++ style guide on members of a base class”

It's probably off-topic because primarily opinion based, but this guy [this video] probably has the most relevant opinion in this case and explains why you should not follow the google style guide.