Why is D unpopular?

Tejas notrealemail at gmail.com
Fri May 20 06:40:30 UTC 2022


On Thursday, 19 May 2022 at 20:17:36 UTC, Dukc wrote:
> On Thursday, 19 May 2022 at 18:39:51 UTC, Walter Bright wrote:
>> On 5/19/2022 12:30 AM, Dukc wrote:
>>> [...]
>>
>> I'm aware of that, but if the user selects "ignore the 
>> asserts" then he assumes the risk of what happens if the 
>> assert would have otherwise tripped.
>
> Agreed. But asserts are often used without regard for 
> performance, because it's assumed they are removed from release 
> code. Which puts pressure to disable them from a release build
>
>>
>> Just like if the user turns off array bounds checking.
>
> We can do a bit better. If an assert trips, the program will go 
> to unknown state, and there's no telling what it will do. But 
> that's still not quite the same as undefined behaviour. If the 
> program trips an assert in `@safe` code, it probably won't 
> cause a buffer overflow vulnerability, because `@safe` would 
> almost certainly have detected a vulnerability if one existed. 
> But if the spec says "undefined behaviour", the compiler is 
> allowed to optimise so that it creates such a vulnerability - 
> see the linked thread for an example. I know the current 
> compilers do not do that, but the spec allows doing so in the 
> future.

Isn't the advice to use `enforce` for handling/verifying input in 
release builds and `assert` for development builds though?
Yeah, it's violating DRY if a particular check needs to be done 
in both development and release, but then one can skip the 
`assert` and just do `enforce`, no?


More information about the Digitalmars-d mailing list