Skip to content
0:00 / 0:00

#exceptions#rtti#zero-overheadprinciple

De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter CppCon 2019

CppCon

189K subscribers • 101 videos on Hallway • Conference channel

YouTube
  • Recommended by 3 people: 3 on Hacker News.
  • A classic. People kept recommending it from 2020 to 2025.
  • Presented by Herb Sutter, C++ Standards Committee chair
  • Linked in the descriptionCppCon/CppCon2019
  • An opinion. It argues one side of a question engineers disagree on.

Advanced. Deep dive for people who know the field.

89K views7 years ago3 recommendations

Programming languagesSystems programmingC++Language design and type systemsPerformance and optimization

Herb Sutter proposes a zero-overhead exception model for C++ to address community fragmentation caused by disabling exceptions and RTTI.

CppCon.org Discussion & Comments: reddit.com/r/cpp/ Presentation Slides, PDFs, Source Code and other presenter materials are available at: github.com/CppCon/CppCon2019 — De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable A fundamental reason why C++ is successful and loved is its adherence to Stroustrup’s zero-overhead principle: You don’t pay for what you don’t use, and if you do use a feature you can’t reasonably code it better by hand. In the C++ language itself, there are only two features that violate the zero-overhead principle, exception handling and RTTI – and, unsurprisingly, these are also the only two C++ language features that every C++ compiler has switches to turn off and that are regularly discouraged or even banned. This matters because not using these features is the largest current cause of fragmentation of the C++ community into incompatible dialects, and the cause of recurring problems including type confusion security vulnerabilities arising from “didn’t down-cast using dynamic_cast because that would be too slow.” This talk is about ongoing long-term efforts to try to unify the community in this area, not by replacing exceptions and RTTI, but by doubling down: fully embracing exceptions and RTTI, and improving them so they can be zero-overhead too. — Herb Sutter Herb is an author, designer of several Standard C++ features, and chair of the ISO C++ committee and the Standard C++ Foundation. His current interest is simplifying C++. — Videos Filmed & Edited by Bash Films: BashFilms.com Work at Hudson River Trading (HRT): tinyurl.com/safxfctf

Why it's here

3 people recommend this

What people say. Engineers recommend this talk for its deep dive into the performance overhead of C++ exceptions and the proposed Result-like alternative.

Moments people linked to

je42on Hacker News • Recommends

On “Tim Sweeney: Eliminating C++ exceptions gave 15% speedup”

Quite an improvement. However, i feel like that the tweet also displays the (sometimes emotional) feelings toward exceptions that a large part of the C++ community has. Herb Sutter made an excellent presentation about this "fragmentation" of the community and steps towards fixing this split: link to this video

Felkon Hacker News • Recommends

On “Investigating the Performance Overhead of C++ Exceptions”

If you want to see Herb Sutter's take on exceptions (and RTTI), I can really recommend this talk where he explores his Result-esque (like in Rust) solution that he wrote a paper about and proposes for standardisation: link to this video

je42on Hacker News • Recommends

On “These Modern Programming Languages Will Make You Suffer”

Wow: C++ > Garbage collection was never added into C++. Manual memory management is extremely error prone. C++ has memory management simplification: reference couting via shared_ptr/unique_ptr. The trade-offs are different, but in C++ manually managing memory is not necessary unless you have a good reason. > C++ is notorious for its slow compilation time. Significantly slower than Java, not as bad as Scala. That depends on what you use and how you use it. However, this is tricky to figure out what slows down the compilation. > In C++, all references are nullable. Looks like this guy really needs to read up on C++. References can point to null, but not so easily. I think he means pointers. >…

inetknghton Hacker News • Recommends

On “How is Ultrassembler so fast?”

> I don't have enough time to watch these kinds of presentations. Then let me pick and share some of my favorites that I found enlightening, and summarize with some information that I found useful. By far, the most useful one is Khalil Estell's presentation last year 0. It's a fairly face paced but relatively deep dive into exception mechanics. At the end, he advocates for a new tool that would audit a program to determine what exceptions could be thrown. I think that's a flipping fantastic idea for a tool. Unfortunately I haven't seen any progress toward it -- if someone here knows where his tool is, or a similar tool, please reply! I did send him an email a few months ago inquiring about…

u/mttdin r/ProgrammingLanguages • Mentions

On “Tutorial for implementing exceptions, RAII in LLVM?”

…n Optimizations. An experiment. 2019-06-04; Gor Nishanov. https://wg21.link/P1676 There's also an alternative (proposed) design: - P0709: Zero-overhead deterministic exceptions: Throwing values. 2018-05-02; Herb Sutter. https://wg21.link/P0709 - De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter - ACCU 2019: link to this video - CppCon 2019: link to this video - An LLVM implementation is discussed in "Low-cost Deterministic C++ Exceptions for Embedded Systems" Compiler Construction (CC) 2019. https://www.research.ed.ac.uk/portal/en/publications/lowcost-deterministic-c-exceptions-for-embedded-systems(2cfc59d5-fa95-45e0-83b2-46e51098cf1f).html These talks are pretty good in…

u/marler8997in r/Zig • Mentions

Zig Vs Herb Sutter's C++ Zero-Cost Exceptions A very nice talk from Herb Sutter (his talks are always worth watching) about potentially adding zero-cost C++ exceptions with no runtime overhead and no dynamic allocation. [video Herb's very good at breaking problems into their core issues and coming up with elegant solutions. He mentions that since there's no good way to handle errors, the community has spawned many different techniques which makes it difficult and sometimes impossible for libraries to inter-operate. Watching it reminded me that Zig is in a pretty good place, as Herb's new proposed exception mechanism is very similar to Zig's error unions and "try" statements. There is…

TuxSHon Hacker News • Mentions

On “TOML for Modern C++”

According to a recent talk from Herb Stutter ( link to this video ), as many as 20% of users fully ban exceptions and an additional 30% ban them partially. Even code doesn't actually reach the throwing paths, exceptions and RTTI induce a huge binary size overhead that is simply not acceptable if you have binary size constraints.

fpolingon Hacker News • Mentions

On “Secure Rust Guidelines”

link to this video mentioned that the notion that C++ could handle out-of-memory was a purely theoretical wishful thinking. In practice it could not.

sideeffffecton Hacker News • Mentions

On “Orthodox C++”

I'm not a C++ developer, but AFAIK the fact that C++ is not 100% "you don't pay for what you don't use" is commonly acknowledged. Exceptions are an example of that. There are ideas/proposals how to fix that: link to this video

oconnor663on Hacker News • Mentions

On “Fork() is evil; vfork() is goodness; afork() would be better; clone() is stupid”

…he "panic on OOM" design of the allocating parts of the Rust standard library, and it's an important part of the story. But I think even if the Linux defaults were different, Rust would still have gone with the same design. For example, here's Herb Sutter (who works for Microsoft) arguing that C++ would benefit from aborting on allocation failure: link to this video . The argument is that the vast majority of allocations in the vast majority of programs don't have any reasonable options for handling an alloc failure besides aborting. For languages like C++ and Rust, which want to support large, high-level applications in addition to low-level stuff, making programmers litter their code with explicit ab…

bluxon Hacker News • Mentions

On “Trip Summer ISO C++ standards meeting (Varna, Bulgaria)”

Does anyone know what happened with Herb's idea for zero-overhead exceptions? I remember liking the idea when he presented it at CppCon ( link to this video ).

u/bisixyfin r/C_Programming • Mentions

On “So, should you handle malloc errors or not?”

It is evil. Loading the entire file for using dynamic allocation is evil. You should use mmap instead (every OS supports mmap). mmap is designed to load large chunk of data. Only fool who deal with std::bad\_alloc which ruins everything. C++ sucks because of std::bad\_alloc. It bloats your binary for 100kbs with no reason. Why do you handle memory allocation failure for heap when you do not deal it with stack allocation failure?[video
-2View on Reddit