[OT] - C++ exceptions are becoming more and more problematic

Alexandru Ermicioi alexandru.ermicioi at gmail.com
Fri Feb 25 13:41:15 UTC 2022


On Friday, 25 February 2022 at 04:09:51 UTC, meta wrote:
> I don't even think the global lock is the only issue, to begin 
> with..
>
> And, no matter what, it's a double penalty in D because it is a 
> Heap allocation, and that can pause all the threads if it 
> requires more memory.. due to the use of a GC

You can throw pre-allocated exception.

> To counter that, one suggested the use of RC, or a value.. but 
> even then, we still deal with exceptions!
>
> No matter what, I personally stopped using exception altogether 
> in my C++ projects, and moving forward, in my new D projects too

You've already mentioned this. Would be more interesting to hear 
how you handle errors/exceptions, or propose a better alternative 
to exceptions that would be comfortable for most people.

> Also I don't think it is wise to design, or hold designs of, 
> the language because you expect people to be lazy, we should 
> have design philosophy based on HW and Software constrains, not 
> based on lazyness/sloppyness of some developers.. we'll attract 
> the wrong user base.. and even then it'll be hard to compete 
> with sloppy dynamic languages out there... javascript... to 
> name a few

Laziness is one of driving forces for automation.
Sloppynes is one of causes for good amount of bugs.

Not taking them into account, would only be harmfull.

> We should all handle our errors and maintain healthy codebases 
> that are safe and make software great again!

Per my understanding if-checking of error codes or similar, was 
proven to be inefficient, or at least more inefficient than 
exceptions, for code which errors happen not so often to affect 
performance.



More information about the Digitalmars-d mailing list