Back in history, white railway workers in America were unhappy about jobs going to Chinese immigrants. We even still have that but with Indians and call them "H1B"s which hides the racist undertones. Yet I've never heard anybody complain about "jobs going to local youths". Somehow a baby born near our house seems to be treated as a more deserving human being than one born somewhere else.
When jobs move overseas, that's usually a good thing, we should celebrate it! It means people overseas are getting more jobs! Very often those are even the same people most in need of more jobs so it's win-win.
It's like applauding McDonald's for replacing its minimum wage workers with indentured servants. They're ignoring basic human expectations about compensation so they can save money.
Now we don't have jobs, but the servants get to live in America! It should be celebrated.
If those people were to receive the same basic rights or fair market compensation for their labor, it would be a positive.
Would you have the same complaints about fair market compensation if an employer starts hiring software developers in low-cost of living areas like Mississippi or Louisiana instead of San Francisco or NYC.
Where unions are likely needed is in the developing world where many workers have unsafe conditions and little to no real rights.
Unions will not protect programming jobs in their resident country short of businesses being encouraged to hire local. How you do that is through various means, least of all is having a favorable employment climate.
The key to your personal success is self improvement and acknowledging when its time to move on. That last piece is the hardest. Its not fun to leave a place you have worked many years but at times it may be necessary