At best you can say “C++ has tried to adhere to zero-cost abstractions, but messed up when it came to exceptions, and is now stuck in a somewhat awkward place where you lose functionality if you want abstractions to be zero-cost”
-
-
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
my understanding of the logic is that, in whatever cost model C++ uses, exceptions are considered zero-cost. i'm not sure if i buy that but i think i see the intent
-
I mean, they add extra control flow edges to calls, which inhibit optimizations…
- 5 more replies
New conversation -
-
-
This isn't really fair. The only way the STL "doesn't work well" without exceptions is that you can't trigger failures from arbitrary operations without them, but any language that allows recovery from that kind of ubiquitous failure is going to have the trade-offs of exceptions.
-
I mean, what do you do if a constructor fails and you don’t have exceptions?
- 4 more replies
New conversation -
-
-
IMO it’s more like “C++ tried to do zero-cost abstractions, but found that adding control flow edges to every call inhibits optimizations, so they’ve tried to claw back performance in a somewhat awkward way with noexcept and -fno-exceptions”
Show this threadThanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
You can disable exceptions and use most of the standard library just fine? Allocation failure would abort, naturally. Also, isn’t the cost of unwind/panic in Rust similar under “zero-cost” EH model?
-
I’m referring to stuff like https://stackoverflow.com/questions/17337602/how-to-get-error-message-when-ifstream-open-fails … where you can’t get an error message from iostream without exceptions enabled. Rust uses Result so that you don’t need exceptions for this.
- 3 more replies
New conversation -
-
-
A dialect of C++ should exist without exceptions. I never use them. None of the numerous commercial C++ codebases I worked on over 2 decades used them.
-
I agree. To the original point, I never thought of exceptions as being a “zero cost abstraction”. I usually see that term used for “this syntax crutch that does compile time checking and generates no runtime code (except for all of the nuanced rules that makes that not true)”
- 2 more replies
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.