Assertions should be more debugger-oriented
nullprogram.com
nullprogram.com
[0] https://docs.unrealengine.com/4.26/en-US/ProgrammingAndScrip...
It would be cool to add a feature to GDB to make the stock assert() work better, something like a "streamline-assert-trace" option that automatically strips the stack trace back down to the program's source. Doesn't sound completely impossible though I know nothing of GDB's internals.
For things that are called a lot and very threaded it's great to not have to lock up the program setting and resuming breakpoints, but the flexibility to be able to introduce new logging as you investigate instead of whatever you thought to log is great.
Tangent: Revisiting Eiffel is on my to do list. IIRC, design-by-contract was a progenitor to (motivator for) assert().
https://en.wikipedia.org/wiki/Eiffel_(programming_language)#...
https://en.wikipedia.org/wiki/Design_by_contract
Young me dismissed Eiffel. Present me kinda likes the syntax. And thinks maybe the overhead of asserting (pre-, post-, invariants) everything could be awesome.
With fuzzing today, you send one stream of input into an entire program, hope for a crash, then figure out where in the entire execution of the program up to that point things went wrong. You have to figure out how to generate inputs that will exercise every pathway. However, if you had pre and postconditions for every function, you could automatically fuzz individual functions!
You don't have to wait for 99% of inputs to get rejected because they don't have the right header. The "unit-fuzzer" would only generate valid inputs for the function it is testing, and check that the function produces valid output, as well as valid inputs for the functions it calls.
If you have n functions of complexity k, fuzzing or verifying an entire program takes time k^n. However, if you have pre/postconditions, you can verify every function with k*n work. If you have enough cores, you can do this in parallel in k time. That's insane.
The article seems to ignore all this, in fact, it argues other languages are even worse than C because assertion failures are exceptions. That seems dubious. In JVM languages assertions descend from a part of the exception hierarchy that normal software rarely catches, so they do tend to propagate to the top of the stack. Nonetheless, the ability to catch an assertion failure and do something with it is useful, because it lets you do things like crash reporting much easier. It also lets you build smaller in-process failure domains.
“assert == true && binding.pry”
I don't know what Delve does, but learning about GDB's Terminal User Interface (TUI) has been a blessing for me in that regard.
`list`
This was my expectation too. It's not always the case in all languages. JavaScript, I found out, just keeps executing a function body even if `console.assert` fails.