1. exceptions have that name because are intended to handle event out of normal , error and not to returns value or information to the caller. No skilled C++ developer will write functions like those, never !
2. In that kind of function exception are useless, in fact that should be write like this, with exception disabled:
int calc(int a, int b) noexcept {
if(... omissis ...) return 1; return 0;
}
3. In case the function had some more complex errors, the correct form for the use of exceptions should be:
int calc(int a, int b) {
try{
// More complex logic here
if(... omissis ...) return 1; return 0;
} catch(myexcept& ex){ // do something // possibly other catch for different except here } catch(...){ // do something }
}
So, not to return information but for error handling.
3. From a skilled developer , from a financial company, I expected a real life example , with correct exception use and a real case in which their presence can slow down a critical section of a program. That could be an interesting lesson;
4. Moreover, the examples are particularly bad because could induce people to think that in other contexts, where performance are not so important, the use of the exceptions in that way is justifiable ! I guess that could be a reason the article was downvoted.
5. I hate "dogma driven programming", IMHO to demonise whole class of features of a language without critical sense is wrong: yes most application has critical sections that are performance sensitive but, also frequently, large portions of them are not. So why make programmer's life miserable banning without think features like exceptions or polymorphism "because is written"? Moreover, if some little parts is justified that are written even in Assembly, maybe large chunks could be written in Go or Python without influence on the general performance of the system.
https://scitechdaily.com/long-considered-impossible-in-physi...
- Author: "They can also operate in many environments, making them particularly attractive for wireless sensors in locations where changing BATTERIES is inconvenient or expensive, such as an underground pipe system or interior aircraft cable ducts";
- CEO: "There is broad demand across the electronics industry to shrink form factors and decrease dependency on BATTERIES and wired power. We believe Graphene Energy Harvesting will have a profound impact on both.”
We really live in a "bullshit amplified by social" society, they took a scientific publication about a phenomenon that needs peer reviews , verifications, etc and transform it in "We have the technology to recharge your phone WITH THE HEAT of YOUR HAND, licenses available !"
- They stole your code embedding it in close commercial crap without credits for the authors nor source code publishing;
- They stole your code using it to create AI appliance that are absolutely not intelligent but act like indirection layer to nullify the license and than they say that developer can be substitute but those "AI" appliances;
- As Mr. Geerling point out, now they shamelessly pass on the GPL license without fear of retaliation;
I hope that the community will do its move, first of all updating the GPL to explicitly forbid this loophole, I'm talking about paywall and illegal restriction of the source code distribution. Moreover , I think some kind of open source licence enforcement organisation should exist. Licenses without enforcement are hot air. For plenty of that organisation Open Source programmers are only simpletons , not dedicated peoples building their fortune. IMHO, I would like to see the possibility to bill for commercial use of open source code easily with license that explicitly cover this area and, again, organisation doing enforcement. Time is a priceless resource and IMHO is inconceivable that corporation etc reduce open source programmers to the role of slave workers of third world countries.