[OffTopic]: Safer usage of C++ in Chrome

Steven Schveighoffer schveiguy at gmail.com
Fri Sep 10 12:10:49 UTC 2021


On 9/9/21 9:24 PM, Adam D Ruppe wrote:
> On Friday, 10 September 2021 at 01:03:58 UTC, max haughton wrote:
>> If I'm not mistaken they do allow exceptions in new code now, their 
>> famous no exception policy was mostly due to them being stuck with old 
>> design decisions.
> 
> Right.
> 
> There's a bad habit among people to say "well company X does this 
> therefore it must be smart for us too", but often company X does it 
> because of some problem specific to their codebase/organization/product 
> which ought not be applied generally.
> 

I once was in charge of maintaining code that targeted a small 
microprocessor. The person who first set up the build didn't know how to 
make the linkfile work with parameters, so it was C code, with *all 
parameters* passed via global variables (why a compiler linkfile would 
be able to mess this up is beyond me).

It was a long time before I figured it out, and the code base still had 
all the parameters as globals. But in actuality, the code the compiler 
generated for it was so horrendous, I kept global variables in all but 
the most trivial cases. It was an 8-bit CPU in a 16-bit address space, 
with only 8K of code ROM space, so every little bit (literally) counted. 
16-bit math was to be avoided at all costs, so no pointers.

For sure, local constraints can dictate why code is written in a weird way.

-Steve


More information about the Digitalmars-d mailing list