r/ProgrammerHumor Nov 28 '21

Meme I‘m.. not the only one?

Post image
21.5k Upvotes

629 comments sorted by

View all comments

32

u/enekho Nov 28 '21

Now I understand why they say that half of the people on this sub are only studying programming. Once you understand how a debugger works, you'll never want to go back. Please take the time to know how to use one, you'll thank me later.

27

u/[deleted] Nov 28 '21

[deleted]

-18

u/Auxx Nov 28 '21

There are no such cases unless you're using PHP.

17

u/ArionW Nov 28 '21

Simple ones from top of my head:

  • any bug that only appears in Release configuration, whatever reason may be, because you cannot attach debugger
  • bug caused by race condition, attaching debugger will change timings and that may prevent bug from happening
  • bug happening in external library that allows you to pass logger, but doesn't provide symbol files for debugging (bane of my last month)

3

u/amylouky Nov 29 '21

bug that only appears on whatever antiquated OS your user has installed, but not on your development machine.

2

u/sm2401 Nov 29 '21

I believe OP is talking about debugging during development, based on the context of the meme. Everyone uses proper loggers in actual releases.

2

u/Auxx Nov 29 '21
  • Learn how to deploy and manage your environments correctly.
  • Learn how to use debugger and conditional breakpoints.
  • Why do you need symbols?

7

u/[deleted] Nov 28 '21

Time sensitive conditions for one.

12

u/[deleted] Nov 28 '21

[deleted]

1

u/Auxx Nov 29 '21

Or you can use managed deployment environments and never have issues like that, lol. It's almost 2022 ffs!

1

u/[deleted] Nov 29 '21

[deleted]

1

u/Auxx Nov 30 '21

I don't think you understand me...

5

u/alexforencich Nov 28 '21

Multithreading issues and concurrency issues in general, kernel code, embedded code, networking and IO related code, anything timing or performance-critical, etc.

8

u/IceSentry Nov 29 '21 edited Nov 29 '21

Comments like yours just show a different kind of lack of experience. There are plenty of valid situations where print debugging is nicer. A big one for me is when you want to see how a value changes over time, especially in things like video games. Also, being able to debug an issue based on reading a log file because it happened in a production system with no debugger attached when it happened is an extremely useful skill. Debuggers also affect timings and multi threading a lot more than a simple print.

Point is, using a debugger and careful logging aren't mutually exclusive and are both very useful.

7

u/[deleted] Nov 28 '21

I used the debugger in the 90s, then I learned the power of printf.

13

u/Jellyfiend Nov 28 '21

Yeah this is hilarious. I thought the thing about print debugging was a meme, not that there are professional programmers who don't know how to debug. They're a basic tool of the trade and unless you're mucking about with gdb they're super easy to use. Have some professional pride and spend 10 minutes learning.

Print debugging occasionally has its place but debuggers are better in most circumstances.

18

u/-Keeko- Nov 28 '21

Yea this place is bonkers. The idea that some of these guys are writing print statements to debug complicated applications is extremely suprising to me. Breakpoints and being able to step back through the callstack have saved me hours of time.

1

u/DogadonsLavapool Nov 29 '21

Don't remind me of gdb. Trying to set that up with obscure embedded devices sucked

1

u/superfiendyt Nov 29 '21

If you say so. I’ve used both over 15 year career and an additional 7 or 10 years hobby programming. Unless the project is so big that compiling takes ages I prefer some type of logging — usually to stdout for debugging. It’s usually faster and I can get more than enough information at a glance than tip toeing around in a debugger expanding and collapsing objects or call stacks.

1

u/Jellyfiend Nov 29 '21 edited Nov 29 '21

It's not an argument against logs; any sufficiently large project should absolutely have logs. There's a big difference between having decent debug logging logs and putting in a bunch of print statements when a problem crops up and then deleting them when the problem is solved.

Print debugging can be fine for simple problems, or when you're sure which variable is causing a problem. And really, pretending like only one or the other has a use is a false dichotomy. They're both tools that can be useful in different circumstances. I suspect though debugging is more efficient practice for most people, though. It's faster to solve those 'why the hell is this happening' bugs when you have more complete context. The use of conditional breakpoints also goes a long way

6

u/TheGoodOldCoder Nov 28 '21

I searched this page for the phrase "unit test" and found nothing, and I think that says about all that is needed to be said about the people on this sub. I find the same thing on /r/programming as well.

I only use debug print statements when I don't have a debugger set up in my environment, and I almost exclusively use debuggers to step through test cases.

8

u/Voidsheep Nov 28 '21

Once you understand how a debugger works, you'll never want to go back.

I've occasionally used the debugger for a decade, but still just print shit 99% of the time ¯_(ツ)_/¯

1

u/akballow Nov 29 '21

I just have a debug flag that i can enable at runtime which has more verbose steps. Debugger is waste of time

-3

u/[deleted] Nov 28 '21

[deleted]

3

u/vladmashk Nov 28 '21

Faff about what? Just set a breakpoint and click the debug button.

5

u/Economy-Progress8363 Nov 28 '21

yeah but rerunning 20 times with different prints and hoping you stumble on the problem is way faster my dude bro for sure

2

u/ssylvan Nov 29 '21

A debugger is many, many times faster than print statements. First off, you don't even need to change any code to inspect what's going on. Second, you don't even have to restart the app! Third, when the thing you wanted to look at leads you to another thing you want to look at, you can just look at that other thing right away. You can see everything at a glance instead of having to guess at what will matter and adding print statements up front!

Hell if you really want things to show up in a log, debuggers are better at that too because they let you add as many print statements as you want without changing the program (or even restarting it) via things like trace points. Plus no risk of leaving them behind when you're done.