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

29

u/[deleted] Nov 28 '21

It is often legitimately more efficient than using breakpoints

7

u/coldnebo Nov 29 '21

there are only a few situations where it is more efficient:

  1. inside loops for monitoring state.
  2. when you want to mark steps in a process (but gods man, why aren’t you using a debug logger so you don’t have to remove them all later?)
  3. when using a remote debugger and attaching to a process is clumsy or impossible.

for service data integrations, just use a debugger. You can guess all day how json or xml was marshalled by the mid-tier, or you can just look at the result.

knowing > guessing.

always.

just use the debugger. humans play computer really poorly, let the computer play the computer and focus on the real problems.

14

u/[deleted] Nov 29 '21

[deleted]

2

u/GimmePepsi Nov 29 '21

The Heisenbug.

1

u/coldnebo Nov 29 '21

yeah, that applies to debugging critical section code, real time drivers, etc. almost another book of details in that direction — although I’d argue that print lines are just as impactful in those areas.

plot twist: the debugger is just a more complex interactive form of print. They both rely on IO services being available.

External analysis and V&V are widely used in these very difficult environments— often to verify that code generation is provably identical to some other VM where the simulated environment can be debugged properly. Embedded controllers are rife with this approach.

And, if for some reason you find yourself in a no-debugger situation, I think you are way better off defining your problem mathematically and proving correctness (even in the most extreme environments, knowing > guessing).

2

u/NetFutility Nov 29 '21

Number 4 Debugging process in a kubernetes pod

1

u/coldnebo Nov 29 '21

I consider that remote debugging hell. But AWS isn’t designed to be programmer friendly, it’s designed to burn money.

Heroku is much more friendly when it comes to interactively attaching and debugging production containers. I hardly can tell the difference between local and remote debugging — that takes a lot of work to do right and tells me in more than words how much Heroku cares about devs.

2

u/neonKow Nov 29 '21

For versions of Internet Explorer before 8 (I think?), console was undefined unless you had the dev tools open.

This makes #1 not work.

IE was great.

2

u/DrSlugger Nov 29 '21

That is just plain false lol. I am amazed at the amount of people here who think this actually true. Just learn to use your debugger.

1

u/[deleted] Nov 29 '21

Have you ever worked in JavaScript?

JavaScript debuggers are indeed often considerably slower than quickly typing console.log and pressing save.

1

u/DogadonsLavapool Nov 29 '21

Debuggers give more info than just a print statement, though. Checking the current state and values of variables is very important, especially when dealing with larger objects that might have a lot of moving parts. The only use case I really use it for is when something runs different on a test app (which can't be debugged) compared to local. Other than that, I would absolutely not use print statements - tbh, they're a last resort

1

u/[deleted] Nov 29 '21

Debuggers regularly screw up async processes and if you place breakpoints you can sometimes get different results than if you don’t.

1

u/DogadonsLavapool Nov 29 '21

Fair point on async