This thread on Hacker News terrifies me

tide tide at tide.tide
Mon Sep 3 03:21:00 UTC 2018


On Saturday, 1 September 2018 at 13:21:27 UTC, Jonathan M Davis 
wrote:
> On Saturday, September 1, 2018 6:37:13 AM MDT tide via 
> Digitalmars-d wrote:
>> On Saturday, 1 September 2018 at 08:18:03 UTC, Walter Bright
>>
>> wrote:
>> > On 8/31/2018 7:28 PM, tide wrote:
>> >> I'm just wondering but how would you code an assert to 
>> >> ensure the variable for a title bar is the correct color? 
>> >> Just how many asserts are you going to have in your 
>> >> real-time game that can be expected to run at 144+ fps ?
>> >
>> > Experience will guide you on where to put the asserts.
>> >
>> > But really, just apply common sense. It's not just for 
>> > software. If you're a physicist, and your calculations come 
>> > up with a negative mass, you screwed up. If you're a 
>> > mechanical engineer, and calculate a force of billion pounds 
>> > from dropping a piano, you screwed up. If you're an 
>> > accountant, and calculate that you owe a million dollars in 
>> > taxes on a thousand dollars of income, you screwed up. If 
>> > you build a diagnostic X-ray machine, and the control 
>> > software computes a lethal dose to administer, you screwed 
>> > up.
>> >
>> > Apply common sense and assert on unreasonable results, 
>> > because your code is broken.
>>
>> That's what he, and apparently you don't get. How are you 
>> going to use an assert to check that the color of a title bar 
>> is valid? Try and implement that assert, and let me know what 
>> you come up with.
>
> I don't think that H. S. Teoh's point was so much that you 
> should be asserting anything about the colors in the graphics 
> but rather that problems in the graphics could be a sign of a 
> deeper, more critical problem and that as such the fact that 
> there are graphical glitches is not necessary innocuous. 
> However, presumably, if you're going to put assertions in that 
> code, you'd assert things about the actual logic that seems 
> critical and not anything about the colors or whatnot - though 
> if the graphical problems would be a sign of a deeper problem, 
> then the assertions could then prevent the graphical problems, 
> since the program would be killed before they happened due to 
> the assertions about the core logic failing.
>
> - Jonathan M Davis

Any graphic problems are going to stem probably more from shaders 
and interaction with the GPU than any sort of logic code. Not 
that you can really use asserts to ensure you are making calls to 
something like Vulkan correctly. There are validation layers for 
that, which are more helpful than assert would ever be. They 
still have a cost, as an example my engine runs at 60+ FPS on my 
crappy phone without the validation layers. But with them enabled 
I get roughly less than half that 10-15 fps, depending on where 
I'm looking. So using them in production code isn't exactly 
possible.


What he was talking about was basically that, he was saying how 
it could be used to identify possible memory corruption, which is 
completely absurd. That's just stretching it's use case so thin.


More information about the Digitalmars-d mailing list