this post was submitted on 22 Jun 2023
26 points (100.0% liked)

Programming

13383 readers
1 users here now

All things programming and coding related. Subcommunity of Technology.


This community's icon was made by Aaron Schneider, under the CC-BY-NC-SA 4.0 license.

founded 2 years ago
MODERATORS
 

I know profilers and debuggers are a boon for productivity, but anecdotally I've found they're seldom used. How often do you use debuggers/profilers in your work? What's preventing you? conversely, what enables you to use them?

top 34 comments
sorted by: hot top controversial new old
[–] xian 16 points 1 year ago (2 children)

As a C# programmer I use the debugger every single day, since it's so natural and easy to use as to just run the application. I've grow spoiled actually, when I program in Go or Rust I really miss the "it just works" debugger.

[–] frosty 5 points 1 year ago

Same here. The Visual Studio debugger is excellent, and there's never a day that goes by without me using it.

[–] Jaloopa 4 points 1 year ago

I can't imagine programming without regularly pausing execution to inspect intermediate variables, run some quick checks in the immediate window or set conditional breakpoints. I'm always a bit surprised when I remember there are people who don't work like that

[–] Hudell@lemmy.dbzer0.com 10 points 1 year ago

I use debuggers all day every day. If I'm running something in development, there's a very good chance I have it connected to a debugger. Also use it whenever I encounter an unexpected behavior in production (we use our own product for work too)

The profiler is a lot more specific and I haven't used it in a while.

[–] Frederic 8 points 1 year ago (1 children)

Really often, even since TurboDebuger in the 90s, no other way to trace your code, step over/into, watch variables, etc. For compiled program it's necessary. For javascript I use print lol

[–] drwho 2 points 1 year ago

Don't forget being able to watch the stack in realtime, and run your code backwards to roll back its state!

[–] Nicktar 6 points 1 year ago

I seldom use profilers because I seldom need to. It's only usefull to run a profiler if your programm has a well defined perfomance issue (like "The request should have an average responsetime of X ms but has one of Y ms" or "90% of the requests should have a response after X ms but only Y% actually do).

On the other hand I use a debugger all the time. I rarely start any programm I work on without a debugger attached. Even if I'm just running a smoke test, if this fails I want to be able to dig right into the issue without having to restart the programm in debug mode. The only situation, where i routinely run code without a debugger is the red-green-refactor cycle with running unit tests because I'll need to re run these multiple times with a debugger anyway if there are unexpected reds...

What enables me? Well there's this prominent bug-shaped icon in my IDE right besides the "play button", and there's Dev-Tools in Chrome that comes with the debugger for JS...

Running your code without a debugger is only usefull if you want to actually use it or if you're so sure that there aren't any issues that you might as well skip running the code altogether...

[–] cnk@kbin.dk 5 points 1 year ago

I have a tendency to just use console logging, and only use debuggers when things are starting to get hairy.

[–] sjolsen 3 points 1 year ago

At my last job, doing firmware for datacenter devices, almost never. JTAG debugging can be useful if you can figure out how to reproduce the problem on the bench, but (a) it's really only useful if the relevant question is "what is the state of the system" and (b) it often isn't possible outside of the lab. My experience with firmware is that most bugs end up being solved by poring over the code or datasheets/errata and having a good long think (which is exactly as effective as it sounds -- one of the reasons I left that job). The cases I've encountered where a debugger would be genuinely useful are almost always more practically served by printf debugging.

Profilers aren't really a thing when you have kilobytes of RAM. It can be done but you're building all the infrastructure by hand (the same is true of debugger support for things like threads). Just like printf debugging, it's generally more practical to instrument the interesting bits manually.

[–] codus@leby.dev 3 points 1 year ago

I find debuggers are used a lot more on confusing legacy code.

Lately, monitoring tools such as OpenTelemetry have replaced a lot of my use of profilers.

[–] drwho 2 points 1 year ago

These days? Never, but I'm mostly writing Ansible and Terraform at work.

When I was writing any code at previous jobs? Also never. It was one part we were highly restricted in what we were allowed to use (and I didnt feel like trying to get gdb through the approval process; it was far easier to just use print statements inside of conditionals) and one part the languages all being scripting languages.

[–] Lenguador@kbin.social 2 points 1 year ago

For microcontrollers, quite often. Mainly because visibility is quite poor, you're often trying to do stupid things, problems tend to be localized, and JTAG is easier than a firmware upload.

For other applications, rarely. Debuggers help when you don't understand what's going on at a micro level, which is more common with less experience or when the code is more complex due to other constraints.

Applications running in full fledged operating systems often have plenty of log output, and it's trivial to add more, formatted as you need. You can view a broad slice of the application with printouts, and iteratively tune those prints to what you need, vs a debugger which is better suited for observing a small slice of the application.

[–] xylem 2 points 1 year ago

Pycharm debugger has been great for me recently, I love the feature where you can drop into an ipython repl and interact with your program state.

My primary languages are Java (for work), Javascript (for work), and C/C++ (for hobbies). Earlier in my career, I used to use the debugger a lot to help figure out what's going on when my applications were running, but I really don't reach for it as a tool anymore. Now, I'll typically gravitate towards either logging things (at a debug level that I can turn on and off at runtime) or I'll write tests to help me organize my thoughts, and expectations

I don't remember when, or if ever, I made the deliberate decision to switch my methodology, but I feel like the benefit of doing things in logging or tests gives me two things. 6 months later, I can look back and remind myself that I was having trouble in that area; it can remind me how I fixed it too. Those things also can serve as a sanity check that if I'm changing things in that area, I don't end up breaking it again (at least breaking it in the same way)

With that said, I will reach for the debugger as a prototyping tool. IntelliJ IDEA (and probably other Java debuggers) allow you to execute statements on-the-fly. I'll run my app up to the point where I know what I want to do, but don't know exactly how to do it. Being able to run my app up to the point of that, then pause it and get to try different statements to see what comes back has sped up my development pretty well. Logging or testing don't really apply for that kind of exploration, and pausing to run arbitrary statements beats the other options in how quickly and minimally that exploration can be done

[–] JesterXIII@kbin.social 2 points 1 year ago

I used to just use print statements and avoided debuggers because I didn't understand it. But as I've gotten more experienced, it's become my first choice in debugging now (go figure haha).

[–] letsgo@lemm.ee 2 points 1 year ago

C# dev here. Quite frequently. When writing new code, instead of trawling the docs looking for what odd name the thing I'm looking for has been given, especially when it's several layers deep in a structure where each layer has dozens of members, to see where in the data structure the value I'm looking for is, makes it a lot easier to determine the next few lines of code to write.

[–] miniu 2 points 1 year ago (1 children)

This usually depends on which industry you work in, and what language you're using usually :)

I work in gamedev, c++, and I ALWAYS use a debugger. There's no running the game, or even the editor without the debugger connected. No matter if you need it currently or not. You always launch the project through the debugger so if anything comes up you can investigate immediately.

Profiler is used any time there's a performance problem.

[–] miniu 2 points 1 year ago

What enables me to use them is probably that this is very much true for the whole industry so software is built with that in mind.

For example, we use special "print" statements for some of the errors that if a debugger is running, it will automatically stop the program so you can investigate. Without a debugger, it will just output the error in the log.

There is no docker, the app is running usually on your local hardware. Consoles are also built with debugger support that you connect to from your PC. So it's very easy to use. Even connecting to another PC in a local network, for example, an artist or tester hardware, is possible from your computer without a problem. We have all the tools prepared for that.

[–] mike901 2 points 1 year ago

All the time. I deal with a lot C# code that makes and responds to HTTP API requests, and being able to check if requests and responses are properly formed without having to slap print statements everywhere is a godsend.

[–] TheTrueLinuxDev 2 points 1 year ago* (last edited 1 year ago) (1 children)

One of the thing I learn about in programming is that, if you have to use debuggers too often then maybe it's a good time to re-evaluate on how you develop a project.

  1. Did you misunderstand the pattern design?
  2. Were there something you don't understand?
  3. Maybe it's an indication that you need to document more and do some project designs before committing the implementation?
  4. Were the way you write code more prone to bugs?
  5. Are there any libraries or tools that can help you alleviate this?

By fixing your practice and making it less prone to bugs, you wouldn't have to resort to using debugger as often.

As for profilers, it really depends, but generally if you try to be conservative like applying lockless concurrency where possible and sometime resorting to mutex/semaphore if otherwise needed, you should generally be ok when dealing with concurrency situation. As for overall performance, the rule of thumb is that, the less code you run to do the work, the better. You can see what program would actually do when dealing with C language for instance, but you might have a harder time to make such evaluation on higher level languages, so the general wisdom is that the heavy computation operation should be deferred to low level language like C language and you should have high level language calls into that C function to handle those performance intensive operations.

[–] pinkpatrol@anarch.is 3 points 1 year ago (1 children)

That's an interesting point about depending too heavily on a debugger. I haven't run into anyone too dependent on it, but I could see that happening.

To me, debuggers offer a tighter dev loop when there's something you're stuck on. They also let you 'grok' a call stack in an unfamiliar codebase. "Did this function get called?" "What's in this variable?" etc.

[–] TheTrueLinuxDev 1 points 1 year ago* (last edited 1 year ago)

That I agree, I always see it as a critical necessity to always document everything when more than 1 developer work on the project. It like making a trade:

Spend time and effort debugging

Or

Spend time documenting and maintain it with the help of Chatgpt

With ChatGPT, it seems to reduce cost for documenting while same can't be said for debugging.

I'm starting to get into the habit of reaching for debuggers more and more as opposed to just print()ing everything and hoping for the best.

Profilers on the other hand I still have no idea how to apply (and more importantly, read the results of) properly, so that's something I'll need to learn.

[–] TweedyImpertinence@kbin.social 1 points 1 year ago* (last edited 1 year ago)

Always, but I’m a former Googler, so performance was always a huge concern with each and every frontend change we made.

Rendering something to a page without errors should be the starting goal, where you then shift focus to readability, accessibility, maintainability, interoperability - all that other stuff that actually matters more but is opaque to users - but in most cases, it’s the end goal, and all that other stuff isn’t considered at all.

IMO, the web would be a lot better if frontend devs spent more time learning how to use their tools instead of logging everything to the console.

[–] CoderKat@kbin.social 1 points 1 year ago (1 children)

My work hilariously doesn't have very good debugging support (mostly just for unit tests), but excellent profiling support even for prod, so I use profiling a ton but debuggers are less useful, due to only being able to use them in fake environments.

[–] pinkpatrol@anarch.is 1 points 1 year ago

What granularity of profiling are you doing in prod?

[–] Kissaki@feddit.de 1 points 1 year ago

Debugger, regularly. To analyse issues, or verify behavior, or test behavior.

Profiler rarely to never. We have performance concerns but not to that degree. When there's performance issues I typically know where it's coming from, and can see and verify through running parts/queries and debugging.

load more comments
view more: next ›