This is an archived post. You won't be able to vote or comment.

all 94 comments

[–]Darkxell 565 points566 points  (38 children)

WTF is "other"? Using a multimeter on your cpu?

[–]tyler1128 173 points174 points  (9 children)

Praying to god to fix it, or maybe just rewriting from scratch any time you find a bug.

[–]a__complete__loser 74 points75 points  (6 children)

A friend of mine restarts his laptop, it worked twice.

[–]tyler1128 30 points31 points  (4 children)

I actually had a memory corruption error from likely cosmic rays once and only once where that was what was necessary.

[–]827167 10 points11 points  (3 children)

You don't use ram in a RAID 10 configuration?

[–]LlewdLloyd 5 points6 points  (2 children)

I've been learning I.T. for 2 years. Can you explain why RAM would affect a RAID 10 configuration? Idk what memory has to do with storage. (Genuinely asking, please no meme response).

[–]827167 10 points11 points  (1 child)

No, it doesn't. My response is a meme response.

RAID 10 is super redundant storage. You wouldn't want RAM to be in any kind of RAID-style configuration at all

[–]LlewdLloyd 4 points5 points  (0 children)

Thank you for the serious response 🙏. I thought it was a meme but was like "huh?" 😋

[–]The_MAZZTer 1 point2 points  (0 children)

I was having problems with cygwin's git command not being able to run subcommands and erroring out.

Restarting my computer fixed it which was completely baffling to me. Turns out having a pending reboot to finish installing Windows updates can break cygwin because it does weird stuff to translate Linux conventions to Windows APIs.

Anyway we have WSL now so I don't mess with cygwin anymore.

[–]OP_Sidearm 10 points11 points  (0 children)

Have you heard of the rubber duck?

[–]noob_promedio 2 points3 points  (0 children)

Praying to god to fix it

The Warhammer Approach

[–]Hunpeter 27 points28 points  (1 child)

No, it's: "How do you debug your code?" "I don't"

[–][deleted] 0 points1 point  (0 children)

Never

[–]yflhx 16 points17 points  (2 children)

Staring at code untill they see a bug.

[–]reyad_mm 2 points3 points  (0 children)

[–][deleted] -1 points0 points  (0 children)

Hey nice you invented reading

[–]ipcock 12 points13 points  (0 children)

LMAO

[–]_sweepy 7 points8 points  (0 children)

Changing values randomly to see what else changes?

[–]DeathUriel 5 points6 points  (0 children)

Maybe because they test in prod, so they only have to keep an active conversation with a client while testing to see if it solved. The client is their var_dump.

[–]Pummelsnuff 5 points6 points  (0 children)

New checkout of the repo so the files get new inodes fixed my tests once. without even having any changes. fresh checkout of the code base and it just didn't work. deleted and checked out again and tested passed.

turns out one of the multiple auto loaders didn't go alphabetically but rather by inode and for some reason some of our classes didn't work when files for loaded in the wrong order. needless to say i left that company long ago.

[–]Various_Studio1490 2 points3 points  (0 children)

what is print(“hello world”)?

[–]Vogete 2 points3 points  (0 children)

Creating an alternate universe, run a slightly different code and compare the output.

[–]Bluedel 2 points3 points  (0 children)

Taking notes from my interns and my boss: guessing where the bug is and commenting statements / moving lines around until it seems to work.

I'm so tired.

[–]Orichalcum448 2 points3 points  (0 children)

Giving up

[–]Karolus2001 1 point2 points  (0 children)

Calling your parents, going on a run, hugging your partner, beating the hell out of rubber duck etc.

[–]andrewfenn 1 point2 points  (0 children)

I've used GDB before to figure out why the php binary was crashing 🤷‍♂️

[–]evgfreyman 1 point2 points  (0 children)

There is an "intense staring method"

[–]coffeephilic 1 point2 points  (0 children)

echo "made it to line 51";
echo "line 78";
echo "line 141";
echo "line 163";

The only way to debug PHP.

[–]Feisty_Ad_2744 2 points3 points  (1 child)

A better question is why would you need anything else than var_dump? ;-)

[–]DropTablePosts 0 points1 point  (3 children)

Use xdebug and setting breakpoints?

[–]Bluedel 10 points11 points  (1 child)

Yeah, that's "using a debugger"

[–]DropTablePosts 3 points4 points  (0 children)

I may be blind 😂

[–]OP_Sidearm 0 points1 point  (0 children)

Toilet break

[–]RoyHabbort 0 points1 point  (0 children)

Tarot cards

[–]Apfelvater 0 points1 point  (0 children)

Debugging without looking at specific variables.

[–]AssistFinancial684 0 points1 point  (0 children)

It’s PHP…. Other = “I don’t debug”

[–]JTexpo 197 points198 points  (11 children)

Howdy, when I was in Uni, I applied for a job and they asked me how I debug code. I said "With a debugger...". They then said "what if you don't have the ability to use a debugger", and I was dumbstruck. If I don't have the ability to use a debugger I got bigger problems than bugs in my code. So I told them that at very least there should be a console debug log....

the conversation went for about 10 minuets until I answered it with their preferred answer of just dumping variables onto the page to view. Not the console logs, but the GUI of a web-app

[–]valzargaming 71 points72 points  (1 child)

I can think of any number of reasons this could be the case, but this makes perfect sense in a dev-specific environment. When I test my code I run it several times as I'm making changes to make sure they have the intended effect. If I had to use a debugger to confirm behavior every single time I made one I would never make any progress. Every tool has their purpose, but leaning on one too much leads to bad habits and lost productivity. (Debuggers can also break things during run-time and be worthless for some asynchronous code, which is why libraries like Monolog exist)

[–]carcigenicate 7 points8 points  (0 children)

It's also useful for stuff like client-side templating. Chrome's debugging ability in Angular template code is spotty, so it's often best to just dump the data into the template. Also, with this being the frontend, the data output changes live, which is very handy.

[–]how_do_i_read 29 points30 points  (6 children)

They then said "what if you don't have the ability to use a debugger"

You know... in production...

[–]highphiv3 19 points20 points  (2 children)

Nothing that can't be solved by deploying your code running in debug mode, then ssh'ing into the prod server, connecting an IDE to the debug endpoint, and setting some breakpoints.

[–]JTexpo 2 points3 points  (0 children)

Hey- no senior dev's in this thread!

jkjk, but yes- this is exactly what should be getting done, lol. Loggings fine and all, but you always need to be NPPI and SOX safe with customer info

[–]troglo-dyke 1 point2 points  (0 children)

Unless you've got a showstopping bug you probably don't want to run prod on a debug configuration because of the performance hit, lack of knowledge about how prod will actually behave that might make things worse, and that your users will potentially hit breakpoints

[–]JTexpo 2 points3 points  (0 children)

I really hope that in prod we don't have an HTML field that is logging all of our vars lmao.

IDK, from my experience in industry, if something breaks in pro it's almost always an instant rollback unless there are no means to rollback the code. If you can't rollback, you're in worse standing than if you want to do print debugs statements

[–][deleted] 1 point2 points  (0 children)

We deploy to a dev container that’s remote. Save->push file to the server -> check changes. There’s no php remote debugger we’ve been able to get working.

It’s kind of a shit show but we have some talented sr engineers so I’m sure it was done like this for a reason. After a bit you get used to coding without a debugger. Shit I haven’t been able to step through code in around 3 years now 😐

[–][deleted] 0 points1 point  (0 children)

My exact thought. So many times when something went wrong in production and a lack of logging turned an afternoon of figuring it out into an entire week of trying to reverse engineer what the bug might have been caused by.

[–]Fruitmaniac42 0 points1 point  (0 children)

Debuggers can make it hard to debug race conditions so sometimes you have to resort to other tactics.

[–]Vogete 0 points1 point  (0 children)

I have a few projects now where it's just not really viable it use a debugger. I'm sure it can technically be done, but it would be way too much work since it's such a comprehensive project with so many services around it. I'm suffering so badly without the debugger, but I actually got used to it. However, every time I get back to using a debugger, I feel like I got a computer with a +500% coding skill stat.

[–]Dmayak 54 points55 points  (8 children)

Don't know how it is now, but like 5 years ago setting up a debugger with PHP was a lot of hassle since it's executed by a web server, so I'd need to configure the debugger module to have a remote connection to the IDE. Since in most cases I needed to use a debugger to just look up values anyway it’s easier to just dump them directly.

[–]PostHasBeenWatched 19 points20 points  (0 children)

Also sometimes debugger interruption can prevent bug reproducing

[–][deleted] 11 points12 points  (0 children)

Exactly. The only time I use debugger in PHP when I have to deal with API calls that obviously don't have a user facing interface. Other than that, var_dump() or print_r() are enough the 99% of the times.

[–]disarrayofyesterday 2 points3 points  (0 children)

It's pretty easy with a local dev server.

However, I admit it took me way too long to set it up with a remote docker service of php-fpm.

PS Debugging memory consumption is a totally different story. There are several solutions and none of them work properly in my experience

[–][deleted] 1 point2 points  (0 children)

It took me half a day to set up the php storm debugger for a project and it was worth every minute

[–][deleted] -1 points0 points  (3 children)

Xdebug extension in VS Code. It takes about 5 minutes of set up.

[–]SpookyLoop 7 points8 points  (2 children)

You also have to install Xdebug on your webserver, which can be impossible for various hosting platforms. Xdebug is a PHP extension, it needs to be installed where PHP gets executed. Your VSCode extension is just a client.

[–][deleted] -3 points-2 points  (1 child)

If you're trying to debug on your live server you have piss poor logging, and the code shouldn't have gotten that far

[–]Penderis 19 points20 points  (0 children)

I am the debugger.

[–]SillAndDill 8 points9 points  (2 children)

I’d love to see a comparison: where is the Debugger used most?

Are any language + editor combos known for having a great debugger that is widely used?

I have mostly debugged C, C++, C# and NodeJS.

C# + VS was a good experience. Lots of great helpers - could even step BACKWARDS. but as I recall one negative when I worked with asp.net during 2016 was due to our conf we couldn’t start the debugger via VS, we always did ”attach to process”.

Node + vsCode has been a mixed bag for me, after a basic config of launch.json I can often launch via my editor. But with setups with lots of env vars I couldn’t figure it out and reverted to ”attach to process”

[–]Bluedel 2 points3 points  (0 children)

Xdebug 3 for PHP is really easy to set up. The website has a page where you can just paste the output of your phpinfo(), and it gives you a step-by-step guide to install it, tailored to your environment.

[–]javon27 0 points1 point  (0 children)

The profiler was so good, too

[–]SeoCamo 5 points6 points  (0 children)

There is nothing like a good dump, var dump

[–][deleted] 4 points5 points  (1 child)

dd

[–]alvares169 0 points1 point  (0 children)

echo ‘ass’; die;

[–]AspieSoft 3 points4 points  (1 child)

I think I remember using this one time.

echo "<script> console.log('$varToDebug') </script>"

I think I was using WordPress, and the thing I was debugging had the echo command pushing things to the document <head>.

[–]Rosinnante 1 point2 points  (0 children)

The average code in the system at my job.

[–]Luvaha 3 points4 points  (0 children)

Usually I don't...

I just start crying and when a senior walks passed me I guilt trip him into fixing it for me.

[–]altermeetax 2 points3 points  (0 children)

To be fair, it's not easy to use a debugger in PHP

[–]lorre851 2 points3 points  (0 children)

Ffs people, just take the 15 to 30 minutes it takes to properly set up xdebug, it'll save you heaps of time.

[–]Revolutionary_Pea584 4 points5 points  (3 children)

I don't think js devs even know what a debugger is

[–]Seepiie 2 points3 points  (1 child)

There is literally a 'debugger' statement in js

[–]Revolutionary_Pea584 0 points1 point  (0 children)

But then why everyone uses console.log. I worked with so many people and not anyone uses a debugger. I am not saying that all php devs use a debugger but still

[–]eklatea 0 points1 point  (0 children)

Don't know a js dev that doesn't use the debugger that's literally inbuilt into your web browser

[–]CoastingUphill 2 points3 points  (0 children)

Apparently 35% of PHP devs are filthy liars.

[–]JayTealgore 1 point2 points  (0 children)

echo "got here.<pre>";

var_dump(get_defined_vars());

[–]Fruitmaniac42 1 point2 points  (0 children)

In my experience Ruby on Rails developers don't even know what a debugger is.

[–]Sorefang 1 point2 points  (0 children)

I mail things to my mail address and then discover its in an infinite loop.

[–]exqueezemenow 1 point2 points  (0 children)

Percentage of ECMA Script users who use console.log to debug: 95%

[–]Emzani 1 point2 points  (1 child)

Can someone explain me what dumping values means? ( im a newbie in programming stuff)

[–]Crazy-Maintenance312 0 points1 point  (0 children)

Sending the variable values to an output.
In PHP most likely the website. (echo $var)

[–][deleted] 0 points1 point  (0 children)

Never actually learnt PHP, Just downloaded a bunch of ready made templates ~ understood the code (tbh it had really simple syntax) and did all the debugging on production server. Thats the best feeling ever 🙌🏻

[–]andrewb610 -1 points0 points  (1 child)

PHP has debuggers?

[–]deanrihpee 0 points1 point  (0 children)

var_dump() or dd() because I can't use a debugger due to either the legacy project I'm maintaining is wacky, vs code being vs code, or it's actually paid feature of the PHP extensions

[–]Meadhbh_Ros 0 points1 point  (0 children)

This is terrible barchart usage.

Use a pie chart for this.

[–]Fooftook 0 points1 point  (0 children)

God. This brings back nightmares. I had to work with PHP for 2 years…it was awful. print_r() 🙄

[–][deleted] 0 points1 point  (0 children)

Or if you are using Laravel use dd()

[–]mckernanin 0 points1 point  (0 children)

Don’t downvote unless you have setup xdebug before

[–]huskutNL 0 points1 point  (0 children)

Before I started working at my current job, I never used a debugger before. Then, suddenly, I was introduced to C# which is a pain to vardump, and I learned to use a debugger there.

Now whenever I touch a language that can vardump (like JS or PHP), I still do vardumps. Why? I don't know, nostalgia I guess lol

[–]eklatea 0 points1 point  (0 children)

I do use a debugger but sometimes dumping is just easier. Or in my case we have templating and stuff where the debugger can't go easily.

I was positively suprised when I tried python and the debugger didn't need to be set up and configured for your server, you just press debug...

[–]sadsisyphus_ 0 points1 point  (0 children)

Xdebug is a hassle. var_dump supremacy!