If tech companies weren't shit at training they would be somewhat more fungible, though not perfectly so. Engineering companies are somewhat better at this: if a company is looking for chemical engineers and can't find someone with experience in exactly the process they're hiring for, they'll hire a chemical engineer with experience in a different process and get them up to speed. Tech companies seem incapable of doing that, and instead they have a big list of really specific background they want, "must have 7 years of experience in J2EE and 3 years experience using Joe Bob's Serialization Framework", then complain they can't find anyone so it must be a "programmer shortage".
At which point they bring a foreign worker over and train them in J2EE and Joe Bob's Serialization Framework.
I've written about this at length in the past. My own wife came over on an H1A as a nurse. The reason that they got her had nothing to do with a "shortage of nurses". Instead, it had to do with a "shortage of nurses that would work for the shit wages that the nursing homes wanted to pay". Big difference - and frankly that's the same thing I see in the tech industry.
If the Department of Labor simply forced these companies to follow the law and compensate the foreign workers on par with American workers it would somewhat alleviate the problem. But they don't, and the law's a joke.
The other issue is that these workers are essentially indentured servants until they get a green card and the power disparity also plays heavily into this. Looking at my wife's situation again I know of nurses who pissed off the wrong people in their job and ended up on a plane back home. If you hate your job you don't have the ability to simply get another. I'd like to say that everybody acts like an adult and that doesn't matter but the reality is that it matters a lot. When you don't really have the option to quit there's little pressure on management to make sure you like your job.
In the nursing industry it's even worse because of regulation. I don't mean the regulation makes it worse - hiring foreigners is a great way to get around regulation and not worry about your employees turning you in. After all, if your understaffed shit hole gets shut down by the state you get a plane ride back home.
In my wife's generation this was even worse because they had to come up with US$5000 to pay the staffing agency to bring them over. That's about a year and a half of wages for your typical middle class Filipino - it would be analogous to an American coming up with $75,000. Not easy. And if you lose your job in America you'll spend 10 years working in the Philippines to pay that off.
Ugh.