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

Programmer Humor

19589 readers
771 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
 
you are viewing a single comment's thread
view the rest of the comments
[–] [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] 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