CppCon 2015 has ended
Back To Schedule
Thursday, September 24 • 2:30pm - 3:00pm
Null pointers shouldn't compile: how Dropbox uses the type system to enforce contracts

Log in to save this to your schedule, view media, leave feedback and see who's attending!

Tony Hoare called null pointers a “billion-dollar mistake”, but nearly every language in wide use today has them. There have been many efforts to reduce the risk of nulls creeping in where they shouldn't be, but most involve attributes or annotations rather than being part of the type system itself. Can we do better? C++'s customizable value types make it possible to solve this sort of problem.

In this talk, I’ll present a non-nullable pointer wrapper, `nn`, that’s found wide use in Dropbox’s C++ code. This helper lets us use the type system to track pointers that can't be null, and express and enforce contracts at compile time. I’ll go into some depth on the template trickery needed to make things “just work”, the toolchain bugs we found along the way, and how this tool has helped us improve our code.

avatar for Jacob Potter

Jacob Potter

Software Engineer, Dropbox
Jacob Potter is a recovering embedded systems engineer who is now driving Dropbox’s use of modern C++ for cross-platform mobile development. He's also the primary maintainer of Djinni, the tool Dropbox uses for generating cross-language bindings.

Thursday September 24, 2015 2:30pm - 3:00pm PDT
Franklin (407) Meydenbauer Center

Attendees (0)