by otabdeveloper2 · 7y ago · 0 comments
There are only languages where exceptions need to be hand-rolled in an ad-hoc fashion.
This ad-hoc approach does not work. It gives you tiny benefit of not needing to learn a language feature. Meanwhile, ad-hoc exceptions mean that you lose all sense of modularity in your program. Real programs are composed of dozens of modules at various levels of abstraction, communicating together over multiple processes and threads. Ad-hoc exceptions in a real program in practice means 'just crash the whole thing, yolo'.
That does not work for serious programs.
C has no exceptions. It seems to be quite successful.
if(f(blah) != E_OK) {
return E_WHATEVER;
}
(which is veeeery common in C) you are reimplementing exceptions by hand (and with less performance in the no-error case since you still pay for the branches, while a C++ code with exceptions would just be a sequence of function calls without branches in that case)