The statement "the first to give a number loses" is fundamentally wrong.
The reality is "the one who doesn't know the value or isn't willing to walk away 'loses'."
Rather than trying to nickle and dime the potential employer during salary negotiations, you need to know ahead of time exactly what it is you want. Then you need to be prepared to walk out and not look back if you don't get that amount. You also need to be prepared to be happy with getting that amount, even if they say yes with zero negotiation.
If you are desperate, or just have to have this particular job for whatever reason, then you lose. If you don't have a very real sense of your worth, you lose.
However, if you understand that there are a lot of companies out there and are capable / willing to spend the time to find the diamond, then you will win. This absolutely requires you to know what the market rates are for what you do. If you have unrealistic expectations - $1m/year for recent college graduate - then you will be 'educated' along the way.
What about large employers who have the power to absolutely require
all candidates to reveal detailed salary history?
This doesn't matter. Yes, companies use that as a starting point. However, you aren't forced to accept their offer. If you were previously making $10/hour and now want $30/hour - and that's in line with the job market - then you can stand your ground on what you want. It's just a starting point to give them an estimate of what they think you'll be willing to take.
How do you avoid wasting everyone's time by being completely out of
range of what the company is willing to pay?
I ask the recruiter very early in the process what the pay range is. If it isn't at least close to what I want then I tell them where they need to be before I would even consider talking further. If they aren't willing to tell me, I decline to interview.
Isn't it possible to "lose" more by seeming difficult to work with
than to simply ask for a generous salary right at the beginning of the
discussion (when the recruiter/hiring manager brings it up, of
Only if you are desperate. The key here is to force the issue early on. You bring it up before walking in the door for the interview. For example, you submit an application, they call you to schedule an interview, before setting the time you ask what the pay range is. If they don't answer, don't waste your time. If they say something nebulous like "market rate" - ask them what that means to them. If the range is roughly what you want, even if they are 10% lower, then go interview. They'll ask what you want at that time, tell them.
Salary negotiation really isn't hard. The key is just to know what it is you want before you even submit an application. Everything that follows is just theater.