CppCon 2018: Kate Gregory “What Do We Mean When We Say Nothing At All?”

CppCon · 19K views · 2018 · 1:01:14

Open on YouTube

C, C++, Rust, Go & systems languagesProgramming language designSoftware practice, open source & careerstalk

Why Stack Overflow recommends it

Stack Overflow users link it when explaining why omitting or including const, virtual, and explicit returns communicates intent, and why C++'s defaults often work against the programmer.

Recommended by 3 people across 5 different months, 2019 to 2023.

What it is

A CppCon 2018 conference talk by Kate Gregory on how the absence of keywords or punctuation in C++ (not writing const, virtual, or a reference marker) carries meaning to readers. She looks at when that silence is a deliberate design choice versus an accidental reliance on defaults, and how to make intent clearer.

What people said

Strong rec StoryTeller - Unslander Monica · 2019-04 · Stack Overflow · on “Design implications of returning a function with void”

I won't say `bar3` is universally good, but sometimes an explicit return can tell far more than simply flowing off the end. Kate Gregory incorporated this point into her CppCon 2018 talk [this video] . You can get a lot of food for thought about such matters from the talk, and I highly recommend it.

Strong rec JohnFilleau · 2020-04 · Stack Overflow · on “What is the point of the "const" keyword in C++?”

A great talk by Kate Gregory on the use or omission of certain keywords, including `const`. Worth the hour. [this video]

Recommends Eljay · 2021-06 · Stack Overflow · on “Why aren't all functions virtual in C++?”

@NikitaDemodov • I think so, yes. Because I agree with Kate Gregory in her presentation What do we mean when we say nothing at all? [this video] about C++ having "all the defaults are wrong". Alas, that ship has sailed.

Recommends Eljay · 2021-08 · Stack Overflow · on “I'm doing type conversions in C++. Came across this program and I don't understand how the constructor `rec(polar p)` is being called”

If you want to feel better about your confusion, Kate Gregory's presentation touches upon C++'s *all the defaults are wrong* [this video] . Unfortunately, it's way too late to fix the problem, short of making a different language. That ship has sailed.

Recommends Eljay · 2022-02 · Stack Overflow · on “no warning for missing ctor initializer list?”

@TedLyngmo • Kate Gregory What do we mean when we say nothing at all? [this video] from CppCon 2018, where she laments that in C++ *all the defaults are wrong*. I concur with her assessment. (And hence, also, my "Alas, that ship has sailed." To paraphrase Donald Rumsfeld, "We do not program in C++ with the language we want; we program in C++ with the language we have.")

Cites Ron Burk · 2023-09 · Stack Overflow · on “Neatest way to loop over a range of integers”

And to elaborate on @bers comment, marking the iterator variable `const` informs the reader you do not expect it to be tinkered with in the loop and tells the compiler to enforce that expectation. If you do this consistently in a project, then absence of `const` is a flag to the reader it *will* get tinkered with. Example of Kate Gregory's "saying nothing": [this video]