Live data from Hacker News

Printf debugging is ok

polymonster.co.uk

21–30 of 152 posts

Re: Printf debugging is ok

#21

all the rest of the stuff is okay but seriously? 2 finger typing? as a programmer? you're gonna be there for AAAGES and your keyboard probably runs a sidebusiness with how long it takes you to type I know I'm stirring up shit here but there really are benefits to touch typing (I mean just think about it, using 10 fingers instead of 2 is gonna be so much faster assuming you have 10 dingers)

I'm a programmer, not a secretary, I don't need more than 2-4 fingers because I don't need to write code that fast. I don't understand why anyone who writes code that is not semi-trivial would need to write code so fast they needed to touch type.

There are ergonomic issues too. Hunt and peck gives you a lot more flexibility as to how you can use a keyboard.

Most programmers who don't touch type can type pretty fast. There is more than one way to do it, and I'm not convinced touch typing is the right one.

Re: Printf debugging is ok

#22
>The main arguments are “if you need to use a debugger you’re an idiot and you don’t understand the code you are writing” (that’s not an actual quote but there was a similar take along those lines). Then there is “If you can’t use a debugger you’re an idiot”. The hating on the ‘printf’ crew is omnipresent.

My holier-than-thou take on this topic is: Whenever possible, debug by adding assert statements and test cases.

Re: Printf debugging is ok

#23
25 years ago I worked on a port of PC -> Playstation 1 game. We did not had proper devkits, but the yaroze model ("amateur", allowing for "printf"-debugging of sorts)

Long story short, our game worked as long as the printfs we had were kept, we had macro to remove them (in "Release/Ship") but the game crashed.

The crash was due to side-effect of printf clearing some math errors.... So here you go!

Re: Printf debugging is ok

#24
As with so many categorical guidelines, there are circumstances to use it and circumstances to not.

The key insight is that printf() is a heavyweight operation ("What, you want to build a string? A human readable string? Okay, one second, lemme just pull in the locale library..."). If you're debugging something at the business-logic layer, it's probably fine.

If you're debugging a memory leak, calling a function that's going to make a deep-dive on the stack and move a lot of memory around is likely to obscure your bug.

Re: Printf debugging is ok

#26
post #3

Whatever works so I can fix it and be home on time. I will even print (in paper) the code and step through it with a pen. Again, whatever works. Also, will we ever move forward from these sort of discussions? Back when I was a mechanic no one argued about basics troubleshooting strategies. We just aimed to learn them and apply them all (as necessary).

> Whatever works so I can fix it and be home on time. I will even print (in paper) the code and step through it with a pen.

I’ve found before that sometimes I can’t see what’s wrong with the code on my screen but I can when I print it out. I think the printed page activates different regions of the brain compared to looking at a computer screen

Re: Printf debugging is ok

#27
Of course it's okay, and at the same time no one will use it as soon as something else is more convenient & effective.

Been waiting for "something else" ~30 years & counting.

Re: Printf debugging is ok

#28

all the rest of the stuff is okay but seriously? 2 finger typing? as a programmer? you're gonna be there for AAAGES and your keyboard probably runs a sidebusiness with how long it takes you to type I know I'm stirring up shit here but there really are benefits to touch typing (I mean just think about it, using 10 fingers instead of 2 is gonna be so much faster assuming you have 10 dingers)

I've been programming for decades and I like... three finger type. Two index fingers and a thumb. I don't look at the keyboard though (I know where the keys are relative to each other inherently through years of typing this way) and I type at a very high rate of speed for someone using so few fingers.

Re: Printf debugging is ok

#29
post #3

Whatever works so I can fix it and be home on time. I will even print (in paper) the code and step through it with a pen. Again, whatever works. Also, will we ever move forward from these sort of discussions? Back when I was a mechanic no one argued about basics troubleshooting strategies. We just aimed to learn them and apply them all (as necessary).

Based on the "lucky 10k" and the size of the internet, likely not. I'm sure if you find a mechanics enthusiast forum you will in fact find these relatively trivial arguments. It's just the nature of the beast.

I find the key thing to avoid arguments is to not make the options adversarial.

Present them as options. "If you like X, you may also like Y." Leave it to the audience to discriminate when to apply the tool.

Re: Printf debugging is ok

#30

all the rest of the stuff is okay but seriously? 2 finger typing? as a programmer? you're gonna be there for AAAGES and your keyboard probably runs a sidebusiness with how long it takes you to type I know I'm stirring up shit here but there really are benefits to touch typing (I mean just think about it, using 10 fingers instead of 2 is gonna be so much faster assuming you have 10 dingers)

9 fingers... Not 10, 9.

I use both my thumbs on the spacebar to assert dominance on every word.

But now I'm curious, which thumb do most people use on a keyboard?

Post reply on HN