News for hackers. Stuff that matters.
Re:The unreasonable effectiveness of print debugging by sudoit on Saturday April 24, 2021 @05:48PM (#26928461)
I'm working on Swift interpreter and the codebase is fairly difficult to debug. There's a lot of reused bits. So if you put a debug point somewhere trying to capture one behavior, odds are that that line will run 10 times for other work before the relevant part uses it.

So I tend to write a LOT of print statements that flush of debug variables right before I where I want to debug. Then I set a conditional breakpoint so that I can have the logs "stop" right where I want the program to.

Example:

// debug print

let someValueICareAbout = variable...

print(someValueICareAbout)

print("") <- conditional debug point here "if someValueICareAbout == 3"

I think it's technically still "print debugging", because I'm only using the debugger to stop the program so I get a chance to read my output.

Re:The unreasonable effectiveness of print debugging by saagarjha on Saturday April 24, 2021 @06:06PM (#26928569)
Why not just add an action to the conditional breakpoint that prints the value?
Re:The unreasonable effectiveness of print debugging by sudoit on Monday April 26, 2021 @11:56PM (#26951840)
I’m usually constructing those values just for that one-off test. They aren’t there at runtime.

It’s an AST interpreter so sometimes I want to see the value of something that’s 5 properties away inside a syntax node