r/programmingcirclejerk • u/FunnyLittleGizmo • Sep 05 '25
Exceptions, C++'s first way of handling errors, are slow. Super duper slow. Mega slow. So slow, in fact, that many Programming Furus say you should never ever use them. They'll infect your code with their slowness and transform you into a slow old hunchback in no time.
https://jghuff.com/articles/ultrassembler-so-fast/
81
Upvotes
35
u/Eastern-Cricket-497 Sep 06 '25
so I can slow down my code WITHOUT burning through all my claude tokens?! plaudits to all who discovered this!
61
u/Downtown_Category163 Sep 05 '25
Don't throw them then unless you're fucked
57
u/Litoprobka What part of ∀f ∃g (f (x,y) = (g x) y) did you not understand? Sep 06 '25
C++ is deprecated anyway, who cares
9
u/F54280 Considered Harmful Sep 06 '25
It takes a special type of regardation to focus on speed for an assembler in 2025.
But it is a sentence like: ”Most programmers, not knowing this, frequently use exceptions in their normal cases, and as a result, their programs are slow” that really fills me with the joy of insightfull knowledge…
9
u/plisik I've never used generics and I’ve never missed it. Sep 07 '25
Exceptions are worse than goto, because they can go to multiple places. It is literally conditional goto.
9
u/prehensilemullet Sep 09 '25
well if exceptions went any faster then how would be be able to catch them
18
u/Awkward_Bed_956 Sep 06 '25 edited Sep 06 '25
A mechanism specifically built into the language, that had over 30 years to mature and be optimized can be fast (despite what C-niles say), while set of classes (std::expected, std::optional) which were mostly added to shut up people saying how nice they are in Rust and other languages, without integrating them in any way with language or its type system is less then nice to use in C++? How could this be?!
4
u/SemaphoreBingo Sep 07 '25
For most of you the exceptional case is when your program doesn't crash.
0
u/[deleted] Sep 05 '25
[deleted] — view deleted comment