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