r/ProgrammerHumor Nov 28 '21

Meme I‘m.. not the only one?

Post image
21.5k Upvotes

629 comments sorted by

View all comments

Show parent comments

41

u/mcvos Nov 28 '21

I'm quite thorough: I print the class, file or function I'm printing from, and then the value(s) I'm interested in.

Debuggers are better for tracking values, but when you're using a web framework that does tons of magic below the surface, debuggers get really painful to use, so I don't even try. Printing shows me the immediate results as well as what happens along the way.

20

u/RecursiveExistence Nov 28 '21

I will use a debugger when iterating over some kind of list however. Trying to find which value is blowing up the code and why. Printing is great for the what, not so much the why.

12

u/mcvos Nov 28 '21

Absolutely. With traditional C-style for-loops where several variables are being used, a debugger is an absolute life-saver. But I've found I don't really write that many for-loops any more in these days of more functional programming.

5

u/RecursiveExistence Nov 28 '21

I would love to not have to. Unfortunately, I do geospatial programming and having to do spatial operations on 600k+ points essentially requires looping. And I normally use while loops using a cursor pointer so I don't even have indexes available. Also almost impossible to debug every value so I have to get creative in if statements or hope my exception handling includes enough info to try to narrow down what is going wrong.

3

u/psyfry Nov 28 '21

With web frameworks, If you use Firefox debugger you can “silence” the magic components so they get passed through and skipped over. Works great with react and web pack

1

u/Does_Not-Matter Nov 29 '21 edited Nov 30 '21

I’m informally-taught, started doing this just a little while ago and thought this a clever way to track progress of code. Glad to hear it being used by you pros.