C++: No more nulls! (Fixing the billion dollar mistake)
summary
Argues C++ eliminates most nulls by using references and value types for definite data, std::optional for maybe values, and gsl::not_null for remaining pointers; shows concrete examples (make_flyer returning a flyer by value, artist/album members as references, optional song returns, atom/nucleus two‑stage init) and points out return‑value optimization and optional locality benefits. Claims compile‑time errors replace many runtime null dereferences and that not_null deletes nullptr construction.
AI-written summary · about
chapters (22)
- 0:00Intro
- 1:28Outline
- 4:44Optional parameter
- 5:12Late initialisation of member
- 6:54Dereferencing is undefined behaviour
- 8:39Unclear APIs
- 13:22Why is static typing good?
- 14:28What does null do to static typing?
- 15:45Conflating notions
- 16:20Values which can be missing
- 16:46Techniques which allow for missing values
- 17:46References over pointers
- 21:22Values over pointers
- 21:54Return values
- 24:39Use the standard library
- 25:32Maybe techniques are for maybe values
- 27:11std::optional
- 33:36Bug classification Where
- 35:14Remaining pointers
- 35:52Tackle maybe pointers
- 36:39Tackle definite pointers
- 40:24A bright future
related talks
55m“Using Types Effectively"
01h 23mThis is C++ - How to Use the C++ Superpower to Write Better C++ Code
01h 33mSafe and Sane C++ Types
54mWriting C++ to Be Read
01h 29mC++ Core Guidelines - Modernize your C++ Code Base
01h 04m“Sane and Safe C++ Classes”
01h 01mSome Programming Myths Revisited
01h 11mI just wanted to point to something!
