Raymond Chen's take on so-called zero cost exceptions
meta
meta at gmail.com
Tue Mar 1 12:13:51 UTC 2022
On Tuesday, 1 March 2022 at 10:27:10 UTC, IGotD- wrote:
> On Tuesday, 1 March 2022 at 07:50:27 UTC, forkit wrote:
>>
>> We need to refocus on why exception handling was introduced,
>> and not just on it's 'cost'.
>>
>
> Yes, features always comes at a cost. Bounds checking costs CPU
> cycles but most people are OK with the extra cost.
>
> Another thing that I don't understand. Exceptions have been
> around for a long time. In the 90s and beginning of 2000s there
> wasn't much talk about the cost of exceptions. 20 years later
> and computers are a magnitude faster, suddenly exceptions are
> too expensive.
You can disable bounds checking, and it's not the same, you know
before hand the cost and how it affects your program as a whole,
which is not the case for exception handling
It also is a way to design your software, proper error handling
is verbose but leads to better and more portable results, syntax
is simpler, easier to read and to follow
With exception handling, you never know what will throw, or if
something was already catched, or if you catch or cast the wrong
Base type, etc (thanks OOP for yet another level of complexity
btw)
Error codes are just better in every aspects, scales from
embedded to what ever complex solution you have
They are even better when the language understands what is an
'error' at the semantic level
Again, error handling is better in every aspects
Also my use cases for D are system level softwares
(graphics/audio engine, low level networking, automation)
I should mention that I'm not asking for enforcing error handling
to everyone, I just want to make sure I can live and keep
programming by not having to use exceptions at all :)
Also It is a personal opinion, you can't make me use them if I
consider it to be a bad practice, even if some people disagree
with that statement
More information about the Digitalmars-d
mailing list