this post was submitted on 06 Jun 2023
101 points (99.0% liked)

Programmer Humor

32042 readers
1220 users here now

Post funny things about programming here! (Or just rant about your favourite programming language.)

Rules:

founded 5 years ago
MODERATORS
 

I have been troubleshooting this script for weeks and finally found it was trying to divide by zero.

top 7 comments
sorted by: hot top controversial new old
[–] [email protected] 9 points 1 year ago

Just ship it with debug flags so your program always generates a stack trace to the user!

[–] [email protected] 6 points 1 year ago

Panicking on the error is much better than letting the system work continue on an undefined behaviour (good luck with debugging if you are ignoring all assertions)!

[–] [email protected] 4 points 1 year ago (3 children)

Makes me think of devs who debug with print statements instead of a debugger and breakpoints.

[–] [email protected] 8 points 1 year ago

IMO there's a place for both. A print statement will reveal a flaw in the programmer's thinking regarding the control flow of the program and the state at that time. If a print statement gives something unexpected, you know exactly where to look in the debugger. If it gives you what you expected, it reveals the problem may be elsewhere

[–] Fabiozeh 7 points 1 year ago

Well, Kernighan himself said "The most effective debugging tool is still careful thought, coupled with judiciously placed print statements."

If it was good enough for him...

[–] [email protected] 5 points 1 year ago

/me glances sideways at codebase

[–] [email protected] 3 points 1 year ago

would it help if I returned -2147483648?