this post was submitted on 02 Aug 2024
759 points (97.7% liked)

Programmer Humor

19589 readers
671 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 
all 46 comments
sorted by: hot top controversial new old
[–] [email protected] 136 points 3 months ago (1 children)

All the debugging tools in the world doesn’t beat an excellent sense of intuition and putting that print statement exactly where it needs to be.

[–] [email protected] 65 points 3 months ago (3 children)

As linus says, if you need to use a debugger your code is too complicated

[–] [email protected] 38 points 3 months ago (2 children)

He works on Linux where he controls the whole stack down to the metal and I love that for him, but other people have to call library code, and them debug that if it doesn't work as they thought it would.

[–] [email protected] 20 points 3 months ago (2 children)

Well then obviously if you use libraries, your code is too complicated

[–] [email protected] 10 points 3 months ago

Yep that's why I refuse to use standard libraries. It just makes my code too complicated...

[–] [email protected] 2 points 3 months ago

Tell that to my employer

[–] [email protected] 5 points 3 months ago

Right, the amount of times I've had to put breakpoints in Django/DRF code to figure out what's causing that weird undocumented behavior is concerningly large

[–] [email protected] 11 points 3 months ago

Dude can pry my debugger from my cold, dead hands.

[–] [email protected] 5 points 3 months ago

The problem is that sometimes it's not your code that you're debugging

[–] [email protected] 49 points 3 months ago (4 children)

echo __LINE__ . "Moo\n";

Honestly if you're not including the LoC in your debug statement I don't even fucking understand you.

But yeah, senior devs know the power of breadcrumb debugging (because most of us were deeply scarred by gdb).

[–] [email protected] 25 points 3 months ago (2 children)

Did GDB do something bad at some point?

[–] [email protected] 17 points 3 months ago

Yes. It breaks points.

[–] [email protected] 3 points 3 months ago
[–] [email protected] 9 points 3 months ago (2 children)

That's console.trace() for all you JS devs out there.

[–] [email protected] 3 points 3 months ago* (last edited 3 months ago)

I always combine that with objects with the shorthand notation. So you always know what variable has what value without having to remember in what order you printed the variables.

console.trace({i, list});
// {i: 1, list: [0, 1, 2]}
[–] [email protected] 1 points 3 months ago

I also use group and groupend to nicely collapse different logs. and table when i'm feeling funny.

[–] [email protected] 7 points 3 months ago* (last edited 3 months ago)

Don't you want it to look a little nicer? echo __LINE__ . ": Moo!";

I mean, presuming cowsay is unavailable

[–] [email protected] 6 points 3 months ago

dbg!() for Rust users

[–] [email protected] 31 points 3 months ago (1 children)

And when you need something more complex

console.log(1);
[…]
console.log(2);
[…]
console.log(3);
[–] [email protected] 24 points 3 months ago (1 children)

More like

console.log('shit');
[…]
console.log('fuck');
[…]
console.log('ass');
[–] [email protected] 11 points 3 months ago (1 children)

yeah and then you forget about one that makes it into a release and then see it in the console.

[–] [email protected] 11 points 3 months ago

This is the real reason we have linters.

[–] [email protected] 18 points 3 months ago (2 children)

Beep

Boop

Gloop

Glorp

Yeet

Yo

[–] [email protected] 5 points 3 months ago

"Hello worl" if I need something quick

"AAAAAAAAAAAAAAAAA" if I'm lazy and don't want to have to hunt the output logs for it

[–] [email protected] 2 points 3 months ago

That's me..... I do that...................

[–] [email protected] 17 points 3 months ago

This is why I find shaders scary as fuck

[–] [email protected] 10 points 3 months ago (2 children)

tfw I recently worked on a side project where I was too lazy to change the log level but not sloppy enough to use raw printf so I'd just throw stuff into info and then remove the statements once I solved my issue

[–] [email protected] 3 points 3 months ago* (last edited 3 months ago)

[[[[[[[[[ TEST ]]]]]]]]]

[–] [email protected] 3 points 3 months ago

After all, that's why git is there, to help me remember the shit I put all over the place. (Ok, it might have some other uses.)

[–] [email protected] 7 points 3 months ago

dbg!(1) all the time...

[–] [email protected] 7 points 3 months ago

Ahhh, my favourite debugging combo...

echo "<pre>"; print_r( "We are here, we are here!" ); echo "</pre>"; die();

Also fun at parties, hanging out asynchronously, is the ever popular PHP Mail to see if something ran in the background properly, or to get output.