
De-fragmenting C++: Making Exceptions and RTTI More Affordable and Usable - Herb Sutter CppCon 2019
About this video
Herb Sutter's CppCon 2019 talk on the split in the C++ community over exceptions and RTTI. He proposes making exceptions cheaper and more usable, including a zero-overhead, Result-like design.
Why it appears in the archive
Pointed to whenever C++ exception overhead, bans on exceptions or error-handling alternatives come up.
AI-generated summary and labels from the source dataset; verify important details against the video. Source & credits.
From the Hacker News discussion
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: [VIDEO]
Read original comment ↗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: [VIDEO]
Read original comment ↗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. > Catching/throwing errors is the preferred error handling mechanism. I think he should really watch Herb Sutters Video[see 1] on the improvements of exception handling that are in the pipeline. Herb also discusses the alternatives to exception handling. C# > Multi-paradigm? C# has Pattern matching since 8.0 [see 2] Python > Python is dynamically typed, there’s not much more to say about the type system. Dynamically but strongly typed one could say. > In comparison, NPM in JavaScript is the only tool you’ll ever need. JS has Yarn as well... > I don’t recommend using Python for large projects, the language was not built with serious software engineering in mind. no arguments provided... and in fact there are very large python projects out there in the wild. Also, pytest is one of the best tes
Read original comment ↗> 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 it, but haven't received a reply. Nonetheless, the whole presentation was excellent in my opinion. I did see that he had another related presentation at ACCU this year [4] with a topic of "C++ Exceptions are Code Compression" (which I totally can believe -- I've seen it myself in binary sizes), but I haven't seen his presentation yet. I'll watch it later today. Just about anything from Herb Sutter is good. I don't like that he works for Microsoft, but he does great stuff for C++, including the old Guru of the Week series [1]. In particular, his 2019 presentation [2] describes different error handling techniques, some difficulties and pitfalls in combining libraries with different error handling techniques, and leads up to explaining why std::expected came about. He does pontificate a lot
Read original comment ↗According to a recent talk from Herb Stutter ( [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.
Read original comment ↗[VIDEO] mentioned that the notion that C++ could handle out-of-memory was a purely theoretical wishful thinking. In practice it could not.
Read original comment ↗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: [VIDEO]
Read original comment ↗> the reason the "safe" Rust programming language leaves software vulnerable to DOS attacks if it uses the standard library Linux overcommitment is often cited as an argument for the "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: [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 aborts next to every allocation would be really painful. I think it's very interesting that Zig has gone the opposite direction. It could be that writing big applications with lots of allocs ends up feelign cumbersome in Zig, or it could be that they bend the curve. Fingers crossed.
Read original comment ↗