DEV Community

Discussion on: It's Never Too Late To Learn: 3 things my 11yo taught me about coding

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Lately, I've seen quite many people defend print statements for debugging because they're dumb, but they get the job done and I really think they're missing the point.

Print statements are the most versatile debugging output available; they can communicate every last bit of information that is programmatically available from a given state of the application, whereas "advanced" debugging features, while often incredibly useful, provide a much narrower insight into certain aspects of the state of the application.

But even beyond debugging, printing some meaningful application state can help, as you said, to validate the programmers assumptions. Validating your assumptions in short implement-validate-fix-cycles helps in detecting both bugs based on technicalities (typos, syntax, etc.) as well as those based on incorrect assumptions (wrong order of arguments, less information returned from a function than expected, etc.) and, in the latter case, can prevent spending much more time chasing down a path that, as it later turns out, doesn't work because it only works for an incorrect assumption (like wanting to use information that an API just doesn't provide, etc.)

Thread Thread
 
nitya profile image
Nitya Narasimhan, Ph.D

"Print statements are the most versatile debugging output available;"
I couldn't agree more - and it is definitely one of those hills I am willing to die on. I think there is a reason we all "print Hello World!" as the starting point for every new learning journey.

Thank you for this!